jsrussell12
New Member
- Joined
- Mar 24, 2023
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi,
I am trying to create a macro that allows users to click a button and depending on a single cell value, hides certain rows within a range (containing a label and below that a text box).
The macro is for a user form that depending on the single value (Cell M15) could be have no hidden rows based with most complex option and hides some rows to become more simplistic depending on the cell (M15)
For example, if cell M15 was "Simple Form", would hide rows 51-73 and 27-49. If cell M15 was "Full Form", no rows would hide, and if was "Intermediate Form", would just hide rows 51-73.
Code so far is as follows:
Sub Gen_Form()
If Target.Address = "$M$15" Then
If Target.Value = "Simple Form" Then Rows ("27:49", "51-73").EntireRow.Hidden = True
If Target.Value = "Intermediate Form" Then Rows ("51-73").EntireRow.Hidden = True
End If
End Sub
However, when I run the macro, I get an object required error and the yellow code section is highlighted in the macro editor.
Any help would be greatly appreciated!
I am trying to create a macro that allows users to click a button and depending on a single cell value, hides certain rows within a range (containing a label and below that a text box).
The macro is for a user form that depending on the single value (Cell M15) could be have no hidden rows based with most complex option and hides some rows to become more simplistic depending on the cell (M15)
For example, if cell M15 was "Simple Form", would hide rows 51-73 and 27-49. If cell M15 was "Full Form", no rows would hide, and if was "Intermediate Form", would just hide rows 51-73.
Code so far is as follows:
Sub Gen_Form()
If Target.Address = "$M$15" Then
If Target.Value = "Simple Form" Then Rows ("27:49", "51-73").EntireRow.Hidden = True
If Target.Value = "Intermediate Form" Then Rows ("51-73").EntireRow.Hidden = True
End If
End Sub
However, when I run the macro, I get an object required error and the yellow code section is highlighted in the macro editor.
Any help would be greatly appreciated!