Hello,
I am creating a UserForm for the first time and am having a bit of trouble getting a macro to run when an option button is clicked. To avoid writing multiple lines of code to hide various ActiveX controls depending on which option button is clicked, I've written macros to hide various combinations of those controls.
For example (this is in Module1),
Public Sub HideSet1()
fraSet1.Visible = False
lblSet1.Visible = False
OptSet1.Visible = False
OptSet1.Value = False
End Sub
Then, when option button 2 is clicked, I'd like the HideSet1 macro to run. This is the code (in UserForm1) that I've written for that:
Sub Opt2_Click()
Application.Run "HideSet1"
'bunch of other code
End Sub
However, when I run that macro, I get a "Run-time error '424': Object required' error at the first line of the HideSet1 code. I suspect that it may have to do with where I've placed the HideSet1 code or how I've declared the macros (Public vs. Private) or something like that. I've tried various placements and declarations to no avail. Could somebody please help?
Thanking you in advance for your time and expertise.
I am creating a UserForm for the first time and am having a bit of trouble getting a macro to run when an option button is clicked. To avoid writing multiple lines of code to hide various ActiveX controls depending on which option button is clicked, I've written macros to hide various combinations of those controls.
For example (this is in Module1),
Public Sub HideSet1()
fraSet1.Visible = False
lblSet1.Visible = False
OptSet1.Visible = False
OptSet1.Value = False
End Sub
Then, when option button 2 is clicked, I'd like the HideSet1 macro to run. This is the code (in UserForm1) that I've written for that:
Sub Opt2_Click()
Application.Run "HideSet1"
'bunch of other code
End Sub
However, when I run that macro, I get a "Run-time error '424': Object required' error at the first line of the HideSet1 code. I suspect that it may have to do with where I've placed the HideSet1 code or how I've declared the macros (Public vs. Private) or something like that. I've tried various placements and declarations to no avail. Could somebody please help?
Thanking you in advance for your time and expertise.