I have a bizarre VBA problem in Excel, where I either get a “ByRef argument type mismatch” error, or the function simply exits with no message or warning. I could use some help understanding what’s going on.
Here’s the two functions involved (pared down to just reproduce the problem):
Function TranslateB(strItem As String, strSrcList As String, strDestList As String, Optional strSplitCharacter As Variant) As String
TranslateB = “3.5”
End Function
Function TranslateA(strInput As String, strVarname As String) As String
i = 15
strSrcList = Range(“C_InputLists”).Cells(i, 1)
strDestList = Range(“P_InputLists”).Cells(i, 1)
TranslateA = TranslateB(strInput, strSrcList.Value, strDestList.Value, “; “)
MsgBox (TranslateA)
End Function
I call the first function from an Excel cell: =TranslateA(“3.5″,”Label”)
I place a breakpoint in each function. When I press F8 to execute the call to TranslateB(), the code exits with no error. The breakpoint within TranslateB() is never reached, and MsgBox() is never executed.
If I remove the “.Value” modifiers from the end of strSrcList and strDestList, I get a “ByRef argument type mismatch” error.
I’m left with the following questions:
– Why is the code not working?
– Why is the function exiting without an error message?
– How should I be debugging this?
Thanks heaps for any help.