C
Charley Kyd
I'm having a TypeName problem and need some ideas.
To see my problem, put two option buttons from Control Toolbox (not Forms)
on your worksheet. Then, in the Sheet1 module, set up this code:
Private Sub OptionButton1_Click()
Foo OptionButton1
End Sub
Private Sub OptionButton2_Click()
Foo OptionButton2
End Sub
Sub Foo(Button As OptionButton)
Debug.Print "Success!"
End Sub
When I click on an option button I get a Run Time Error 13, Type mismatch.
This is strange, because when I use the Immediate pane to enter...
Print TypeName(OptionButton1)
....I'm told that OptionButton12 is, indeed, an OptionButton.
Obviously, in Foo, I could define Button as a variant. But that just ignores
the problem. Why am I getting an error when I define an option button as an
option button?
Thanks.
Charley
To see my problem, put two option buttons from Control Toolbox (not Forms)
on your worksheet. Then, in the Sheet1 module, set up this code:
Private Sub OptionButton1_Click()
Foo OptionButton1
End Sub
Private Sub OptionButton2_Click()
Foo OptionButton2
End Sub
Sub Foo(Button As OptionButton)
Debug.Print "Success!"
End Sub
When I click on an option button I get a Run Time Error 13, Type mismatch.
This is strange, because when I use the Immediate pane to enter...
Print TypeName(OptionButton1)
....I'm told that OptionButton12 is, indeed, an OptionButton.
Obviously, in Foo, I could define Button as a variant. But that just ignores
the problem. Why am I getting an error when I define an option button as an
option button?
Thanks.
Charley