Currently, I have over a hundred worksheets that I first unhide all rows and then call the Hide_Rows_Script see example code below (in column 20 I sum all numbers in row if (total=0) then I hide if not I don't hide) so the key to hide or not is if total=0 in row then hide. Hope this makes sense. This works fine except it takes a few minutes to run. I would like to get it running quicker -- is there a way to select the 0 zero rows without running a loop to find them? Looking for a quicker code for this? Thanks.
Worksheet wx4 example:
a1=1 b1=1 t1(column 20) = 2 -- don't hide row
a2=0 b1=0 t1(column 20) = 0 -- hide row
a3=2 b1=2 t1(column 20) = 4 -- don't hide row
Sub hiderow()
'This macro evaluates lines to determine rows to be hidden
Sheets("wx4").Select
' Unhide rows
Rows("6:200").Select
Selection.EntireRow.Hidden = False
'Call hide rows script to hide rows, parms are for x(row) and y(column) values
Hide_Rows_Script 6, 20
end sub
Sub Hide_Rows_Script(x As Single, y As Single)
'This routine will loop through row and hide zeros
Cells(x, y).Select
Do While Cells(x, y).Value <> ""
' Hide rows
If Cells(x, y).Value = 0 Then
Rows(x).Select
Selection.EntireRow.Hidden = True
End If
' Increment to next row
x = x + 1
Loop
End Sub
Worksheet wx4 example:
a1=1 b1=1 t1(column 20) = 2 -- don't hide row
a2=0 b1=0 t1(column 20) = 0 -- hide row
a3=2 b1=2 t1(column 20) = 4 -- don't hide row
Sub hiderow()
'This macro evaluates lines to determine rows to be hidden
Sheets("wx4").Select
' Unhide rows
Rows("6:200").Select
Selection.EntireRow.Hidden = False
'Call hide rows script to hide rows, parms are for x(row) and y(column) values
Hide_Rows_Script 6, 20
end sub
Sub Hide_Rows_Script(x As Single, y As Single)
'This routine will loop through row and hide zeros
Cells(x, y).Select
Do While Cells(x, y).Value <> ""
' Hide rows
If Cells(x, y).Value = 0 Then
Rows(x).Select
Selection.EntireRow.Hidden = True
End If
' Increment to next row
x = x + 1
Loop
End Sub