Also you have declared k As String
in the function so the function expects that you pass a String
to it. Since you have not declared k
in Sub Test()
, k
will be considered as a Variant
and hence you are getting that "by ref argument type mismatch" Error.
It doesn't give you an error when you pass curKey
because curKey
is defined as String
in Sub Test()
which is what the function expects...
Another TIP: Please use Option Explicit
at the end of the code.