[VBA] Excel - Using Option Buttons
Solved
IBegin
Posted messages
7
Status
Member
-
nana -
nana -
Hello,
I would like to create two Option Buttons (the buttons where you cannot check multiple boxes at the same time = Excel's OptionButton) and based on which button is checked, redirect the user to one page or another when they click a Validate button.
I hope you understand me!
Thank you in advance
I would like to create two Option Buttons (the buttons where you cannot check multiple boxes at the same time = Excel's OptionButton) and based on which button is checked, redirect the user to one page or another when they click a Validate button.
I hope you understand me!
Thank you in advance
Configuration: Windows XP Internet Explorer 7.0
1 answer
So your message is a bit outdated, but I think that if I respond, it might help someone else:
In the Sub of your Validate button _Click()
If OptionButton1.value = true then
Sheets("Sheet name").visible = True ' Shows the sheet you want
else
sheets("Sheet name").visible = True
End if
Sheets("Main sheet name").visible = False ' Hides the main sheet
End sub
So here's a code that should work. If you have more than 2 optionButtons, you can use ElseIf.
In the Sub of your Validate button _Click()
If OptionButton1.value = true then
Sheets("Sheet name").visible = True ' Shows the sheet you want
else
sheets("Sheet name").visible = True
End if
Sheets("Main sheet name").visible = False ' Hides the main sheet
End sub
So here's a code that should work. If you have more than 2 optionButtons, you can use ElseIf.
Let me explain, I had the same problem for 6 weeks, everything works but not my option buttons,
yet it's simple...
I tried everything, changed the code tons of times... then I saw that someone had almost the same issue as mine with option buttons.
Thanks to both of you, it works, a thousand thanks, I couldn't take it anymore... I reread my school notes dozens of times... and I spent hours in front of VBA for options for something ultimately so simple.
I just read one of your replies on the site and I would like to know if it would be possible for you to help me.
So let me explain.
I created a search userform which I can modify from my userform with textboxes that work very well! However, I would like to add option buttons that I can also modify from the userform, and that works well too! My problem is that when I search from the cells in column A, the points do not appear in the right place.
Could you help me??
Thank you in advance.
Nana