Hello,
Somebody named ZVI posted the VBA code below in 2020 which works really quickly for 1 sheet. I am wondering if this code can be altered to include multiple sheets? For my purpose just call them "Sheet 1", "Sheet 2", and "Sheet 3". Thanks.
Somebody named ZVI posted the VBA code below in 2020 which works really quickly for 1 sheet. I am wondering if this code can be altered to include multiple sheets? For my purpose just call them "Sheet 1", "Sheet 2", and "Sheet 3". Thanks.
VBA Code:
Sub HideRows1()
Dim a()
Dim rng As Range
Dim i As Long
Dim ws As Worksheet
' Disable screen updating (CF triggering) and events triggering
Application.ScreenUpdating = False
Application.EnableEvents = False
' Main
Set ws = ActiveSheet
With ws
.UsedRange.EntireRow.Hidden = False
a() = .Range("K1", .Cells(.Rows.Count, "K").End(xlUp)).Value
' Collect rows to be hidden in the rng
For i = 1 To UBound(a)
If a(i, 1) = "HIDE" Then
If rng Is Nothing Then
Set rng = .Rows(i)
Else
Set rng = Union(rng, .Rows(i))
End If
End If
Next
End With
' Hide rows
If Not rng Is Nothing Then
rng.EntireRow.Hidden = True
End If
' Restore screen uodating and events triggering
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: