I'm trying to write a sub that will accept either text or a value as a parameter and have encountered some behavior I don't understand.
If I take this code:
Sub TestInput(strText As Variant)
MsgBox VarType(strText)
End Sub
and call it from the immediate window
TestInput(53)
I get a messagebox with "2" as expected. If I run it again from immediate with:
TestInput("Test")
I get a compile error, sub or function not defined. If I close excel, open again, run it again with "test" I get a messagebox with "8".
Question is, why doesn't the variant accept a different data type when called successive times?
Jesse
If I take this code:
Sub TestInput(strText As Variant)
MsgBox VarType(strText)
End Sub
and call it from the immediate window
TestInput(53)
I get a messagebox with "2" as expected. If I run it again from immediate with:
TestInput("Test")
I get a compile error, sub or function not defined. If I close excel, open again, run it again with "test" I get a messagebox with "8".
Question is, why doesn't the variant accept a different data type when called successive times?
Jesse