I am attempting to write excel VBA to hide blank rows across multiple worksheets based on cell value in Column A. Sheet 1 is where I use formulas to populate the rest of the sheets so this sheet will need to be excluded from the VBA. Sheet 2-5 are identical in terms of last names displayed and the exact same range/# of empty rows. Sheets 6-8 will look identical to sheets 2-5, but have a different range that will need blank rows hidden.
Sheet 2-5 Range A9-A58:
Column A
Ross
Kirby
George
Stevens
Sears
(blank)
(blank)
(Blank)
Sheet 6-8 Range A16-A65:
Column A
Ross
Kirby
George
Stevens
Sears
(blank)
(blank)
(Blank)
My current VBA code:
The code works only for the active sheet I run the code on and not the other sheets listed. Also, I am not sure where to add the code for Sheets 6-8 with the different range than sheets 2-5. Any help is greatly appreciated!
Sheet 2-5 Range A9-A58:
Column A
Ross
Kirby
George
Stevens
Sears
(blank)
(blank)
(Blank)
Sheet 6-8 Range A16-A65:
Column A
Ross
Kirby
George
Stevens
Sears
(blank)
(blank)
(Blank)
My current VBA code:
Code:
Sheets(array("Sheet 2", "Sheet 3", "Sheet 4", Sheet 5"))
Dim aStart as Long,
Dim aStop as Long,
aStart = 19
aStop = 58
Dim i as Long,
For i = aStart to aStop
If Cells( i, "A").Value = "" Then
Rows(i)EntireRow.Hidden = True
End If
Next i
End Sub
The code works only for the active sheet I run the code on and not the other sheets listed. Also, I am not sure where to add the code for Sheets 6-8 with the different range than sheets 2-5. Any help is greatly appreciated!