onthegreen03
Board Regular
- Joined
- Jun 30, 2016
- Messages
- 168
- Office Version
- 365
- Platform
- Windows
Hi. I have the code below which I'm hoping will hide the non consecutive rows listed, but when I run the code it errors out. The code was working when it was just 2 consecutive rows (1:2), but now that I need to hide/unhide multiple rows (non consecutive) it no longer works. Any help would be appreciated.
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "19,30,43,49,55,86,93,103,109,115" 'change this to the row numbers
If ToggleButton1.Value Then
Application.ActiveSheet.Rows(xAddress).Hidden = True
ToggleButton1.Caption = "Show Row"
Else
Application.ActiveSheet.Rows(xAddress).Hidden = False
ToggleButton1.Caption = "Hide Row"
End If
End Sub
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "19,30,43,49,55,86,93,103,109,115" 'change this to the row numbers
If ToggleButton1.Value Then
Application.ActiveSheet.Rows(xAddress).Hidden = True
ToggleButton1.Caption = "Show Row"
Else
Application.ActiveSheet.Rows(xAddress).Hidden = False
ToggleButton1.Caption = "Hide Row"
End If
End Sub