View Full Version : [SOLVED:] Conditional hiding of rows
K. Georgiadis
02-03-2005, 01:30 PM
Could you help me with the VBA syntax to accomplish the following:
On Sheet1 there will be an option button, with the instruction "click here if this is a multilevel calculation"
If the user clicks the option button, rows A5:A8 in Sheet2 are unhidden. Otherwise they remain hidden
Thanks.
KG
mdmackillop
02-03-2005, 01:55 PM
Try the following
MD
Sub Macro1()
Sheets("Sheet2").Rows("5:8").Hidden = False
End Sub
K. Georgiadis
02-03-2005, 03:01 PM
if this was meant to be a macro assigned to the option button, it did not do the trick for me.
mdmackillop
02-03-2005, 03:31 PM
Try setting up a second option button. The following works for me.
Private Sub OptionButton1_Click()
Macro1
End Sub
Private Sub OptionButton2_Click()
Macro2
End Sub
Sub Macro1()
Sheets("Sheet2").Rows("5:8").Hidden = False
End Sub
Sub Macro2()
Sheets("Sheet2").Rows("5:8").Hidden = True
End Sub
Ken Puls
02-03-2005, 04:50 PM
If it's an option, I personally prefer to use a checkbox, since you can't "unselect" and option button unless you have a second one.
With a checkbox, you can put all your code in one sub:
Private Sub CheckBox1_change()
Select Case CheckBox1.Value
Case Is = True
Sheets("Sheet2").Rows("5:8").Hidden = False
Case Is = False
Sheets("Sheet2").Rows("5:8").Hidden = True
End Select
End Sub
HTH,
mdmackillop
02-03-2005, 05:57 PM
Agreed, The code will only run once with a single option button.
MD
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.