I have a group of 4 option buttons. Each option button relates to a group of three rows. Option button 1 is for rows 49-51. Option button 2 is for rows 53-55. Option button 3 is for rows 57-59. Option button 4 is for rows 61-63. I have cell C44 set as the linked cell for the option buttons, so that if option button 1 is chosen, then cell C44 displays the number 1, and if option button 2 is chosen, cell C44 displays the number 2, etc. Depending on which option button is chosen, I would like Excel to automatically display (i.e. unhide) 3 rows and hide the other 9 rows (i.e. the other 3 sets of 3 rows).
I tried writing a macro and assigning it to the option buttons. The macro I tried to write is:
Sub Hide_Unhide_Rows()
If Target.Address = "$C$44" Then
If Target.Value = "1" Then Rows("49:51").EntireRow.Hidden = False
If Target.Value = "1" Then Rows("52:63").EntireRow.Hidden = True
If Target.Value = "2" Then Rows("53:55").EntireRow.Hidden = False
If Target.Value = "2" Then Rows("49:52").EntireRow.Hidden = True
If Target.Value = "2" Then Rows("56:63").EntireRow.Hidden = True
If Target.Value = "3" Then Rows("57:59").EntireRow.Hidden = False
If Target.Value = "3" Then Rows("49:56").EntireRow.Hidden = True
If Target.Value = "3" Then Rows("60:63").EntireRow.Hidden = True
If Target.Value = "4" Then Rows("61:63").EntireRow.Hidden = False
If Target.Value = "4" Then Rows("49:60").EntireRow.Hidden = True
End If
End Sub
However, I get a run-time error '424'. Can anyone help?
Bookmarks