Hello -
The code below works fine for hiding/unhiding a small number of rows. However, the macro takes a very long to process when there are several rows. Is there way to modify this code to improve its efficiency?
Thanks,
Private Sub ToggleButton2_Click()
'mark9988
Dim xAddress As String
Dim splitAddress As Variant
xAddress = "1,2,3,4,5,6,7,8,9,10" 'change this to the row numbers
splitAddress = Split(xAddress, ",")
If ToggleButton2.Value Then
For Each Var In splitAddress
Application.ActiveSheet.Rows(Var).Hidden = True
ToggleButton2.Caption = "Show Rows"
Next Var
Else
For Each Var In splitAddress
Application.ActiveSheet.Rows(Var).Hidden = False
ToggleButton2.Caption = "Hide Rows"
Next Var
End If
End Sub
The code below works fine for hiding/unhiding a small number of rows. However, the macro takes a very long to process when there are several rows. Is there way to modify this code to improve its efficiency?
Thanks,
Private Sub ToggleButton2_Click()
'mark9988
Dim xAddress As String
Dim splitAddress As Variant
xAddress = "1,2,3,4,5,6,7,8,9,10" 'change this to the row numbers
splitAddress = Split(xAddress, ",")
If ToggleButton2.Value Then
For Each Var In splitAddress
Application.ActiveSheet.Rows(Var).Hidden = True
ToggleButton2.Caption = "Show Rows"
Next Var
Else
For Each Var In splitAddress
Application.ActiveSheet.Rows(Var).Hidden = False
ToggleButton2.Caption = "Hide Rows"
Next Var
End If
End Sub