Macro Tutorial – Hide and Unhide rows in Microsoft Excel (Hide/Unhide VBA code)

posted in: Excel Tutorials | 0

Macro Tutorial – Hide and Unhide rows in Microsoft Excel (Hide/Unhide VBA code)

In this tutorial we outline how to write a macro in Excel which will hide or unhide defined rows when executed. This has a wide number of applications.

If you are new to Excel macros please follow this playlist to then get started with this tutorial.

The code that we have used in this example is as follows. Paste this between “private sub” and “end sub” and edit the rows to fit your purpose.

Rows(“4:6”).Select
If Selection.EntireRow.Hidden = True Then
Selection.EntireRow.Hidden = False
Else
Selection.EntireRow.Hidden = True
End If

 

To download this workbook please click the following link.

Hide Unhide macro worksheet

Leave a Reply