Link to home
Start Free TrialLog in
Avatar of dartanion_jm
dartanion_jm

asked on

Excel VBA Macro to hide/unhide every 3rd, 4th & 5th row

Greetings; I need an Excel VBA Macro to hide/unhide every 3rd, 4th & 5th row on a particular workbook. I found a macro that hides every 3rd and 4th row but I haven't been able to figure out how to modify it to include the 5th row.

Thanks in advance for your consideration.
Hides every 3rd and 4th row:
 
Sub hiderows()
For i = Cells(Rows.Count, "a").End(xlUp).Row - 1 To 2 Step -3
Rows(i).Resize(2).Hidden = True
Next i
End Sub

Open in new window

SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dartanion_jm
dartanion_jm

ASKER

Thanks for the prompt response Rorya.

Unfortunately the script provided unhid the 1st 5 rows; then hid the next 2 rows; unhide the next row then hid the next 3 rows. Still can't figure this script out.  

The original script provided is close...Unhide rows 1 and 2; hide rows 3 and 4.

Just need it to unhide rows 1 and 2; hide rows 3, 4 and 5; unhide row 6; hide rows 7, 8 & 9; unhide row 10; hide rows 11, 12 & 13...and continue on.

Any assistance you can provide is greatly appreciated. Thanks for your efforts.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Greetings Rorya; Sorry for the confusing  (am) explanation.

What I'm looking for (after rows 1 and 2 are left unhidden)  is for rows 3,4, & 5 hidden; then leave row 6 unhidden; then hide rows 7, 8 & 9 and continue on for the rest spreadsheet.

Unhidden
Unhidden
Hidden
Hidden
Hidden
Unhidden
Hidden
Hidden
Hidden
Unhidden

Thanks again.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Matrix (1999) - Morpheus: "You are the ONE, Rorya!"

It works perfectly. Thank You for the prompt responses and your patience.