Excel VBA: Unhide All Rows in a Sheet (Step-by-Step)
In this article
To unhide every row on the active worksheet with VBA, run Cells.EntireRow.Hidden = False or Rows.Hidden = False inside a Sub. That single line resets the hidden state of all rows on the sheet, including rows hidden by filters or by previous macros. You do not need to select the rows first, and you do not need to loop. The steps below show how to add that code to a workbook, run it safely, and what to do when rows still refuse to appear.
What You'll Need
- Excel for Windows or Mac (the VBA editor is included; no add-in required).
- A workbook saved as .xlsm (macro-enabled) if you want to keep the code. Saving as .xlsx removes macros.
- Permission to run macros in your organisation. Some managed devices block macros by policy, and that is not something to work around.
- Basic familiarity with the VBA editor (Alt+F11 on Windows, or the Developer tab on Mac).
Step-by-Step
- Open the workbook that contains the sheet with hidden rows. Save a copy first if the sheet contains important data, because macros change the file permanently once you save.
- Open the VBA editor. On Windows press Alt+F11. On Mac, enable the Developer tab first (Excel > Preferences > Ribbon & Toolbar, tick Developer), then click Developer > Visual Basic. Menu labels can differ slightly by Excel version and region.
- Insert a standard module. In the editor choose Insert > Module. A blank code window appears. Do not paste into the ThisWorkbook or a sheet module unless you specifically want event code.
- Paste the macro. Use this exact code:
This acts on the active sheet only. If you want a specific sheet regardless of which one is active, replace the middle line withSub UnhideAllRows() Cells.EntireRow.Hidden = False End SubWorksheets("Sheet1").Rows.Hidden = Falseand change the sheet name to match the tab name exactly. - Place the cursor inside the Sub and press F5 to run it, or click the green Run button on the toolbar. The code runs against whichever sheet is active in Excel behind the editor.
- Switch back to Excel (Alt+F11 again or click the Excel icon). All rows on that sheet should now be visible. Scroll to confirm; the row headers should run continuously with no gaps.
- Save the workbook as .xlsm if you want the macro to persist. Use File > Save As and choose Excel Macro-Enabled Workbook. If you save as .xlsx, Excel warns that macros will be removed.
- Optional: run it on every sheet. If the workbook has many tabs, use a loop:
This does not affect chart sheets or hidden sheets themselves; it only unhides rows within visible worksheets.Sub UnhideAllRowsAllSheets() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets ws.Rows.Hidden = False Next ws End Sub
Common Mistakes
- Running the macro on the wrong sheet.
Cells.EntireRow.Hidden = Falseuses the active sheet. If the VBA editor was opened while a different tab was active, the wrong sheet gets changed. Always check the active tab before pressing F5. - Confusing hidden rows with filtered rows. If rows are hidden by an AutoFilter, setting
Hidden = Falsemay not reveal them because the filter still excludes them. Clear the filter first withActiveSheet.AutoFilterMode = Falseor by clicking the filter arrow and choosing Clear Filter. - Pasting into the wrong module. Code in a sheet module only runs for that sheet's events. A standard module is the right place for a manual macro.
- Saving as .xlsx. The macro runs once, then disappears on save. Use .xlsm.
- Forgetting grouped rows or outlines. If rows are collapsed using Excel's Group/Outline feature, unhiding them with VBA works, but the outline settings may re-collapse them if the user clicks the group buttons again. Expand the outline manually if needed.
- Assuming it fixes row height. A row can be visible but have a height of zero set manually. If rows look like thin lines, select all and use Home > Format > Row Height > AutoFit.
Tips
- Assign the macro to a button on the sheet (Developer > Insert > Button) so users can unhide rows without opening the VBA editor.
- Add
Application.ScreenUpdating = Falseat the start andTrueat the end if you loop over many sheets; it makes the macro run faster and avoids flicker. - Use
Rows.Hidden = Falserather thanRows("1:1048576").Hidden = False. The short form is cleaner and works across Excel versions. - If you only want to unhide rows in a used range, use
ActiveSheet.UsedRange.EntireRow.Hidden = False. This avoids touching rows far below your data. - Keep a backup copy before running any macro that changes visibility across a large workbook; it is easy to lose track of what was hidden intentionally.
Troubleshooting
If rows are still hidden after running the macro, work through these checks in order.
- Confirm the macro actually ran. Add
MsgBox "Done"as the last line beforeEnd Sub. If no message appears, the code did not execute; check that the cursor was inside the Sub and that macros are enabled. - Check for an active filter. Look for filter arrows in the header row. Clear the filter, then run the macro again.
- Check for grouped/collapsed outlines. Look for the outline buttons to the left of the row numbers. Click the highest-level outline button to expand all groups.
- Check row height. Select all rows (click the corner box above row 1), then set Format > Row Height to a value like 15, or use AutoFit.
- Check sheet protection. A protected sheet blocks row visibility changes. Unprotect it first (Review > Unprotect Sheet) if you have the password. Do not attempt to bypass protection you do not own.
- Check macro security. If macros are disabled by policy, the code will not run. Ask your IT administrator; do not disable security settings yourself.
- Check you edited the right workbook. If multiple workbooks are open, the VBA editor may be showing a different project. Use the Project Explorer on the left to confirm.
Frequently Asked Questions
Does this unhide rows on every sheet at once?
No. Cells.EntireRow.Hidden = False affects only the active sheet. Use a loop over ThisWorkbook.Worksheets to cover all sheets.
Will it unhide rows hidden by a filter?
Not reliably. Filters hide rows without changing the Hidden property in the same way. Clear the filter first, then run the macro.
Can I undo the macro with Ctrl+Z?
No. VBA changes are not added to the undo stack. Save a backup before running macros that change visibility, or re-hide the rows manually.
Does it work on Excel for Mac?
Yes, the same VBA code works in Excel for Mac. The keyboard shortcut to open the editor differs, and the Developer tab must be enabled first.
Why do rows reappear as hidden after I reopen the file?
The workbook was probably saved as .xlsx, which strips macros, or the rows were re-hidden by an outline or filter on open. Save as .xlsm and check for filters and groups.
Can I unhide only a specific range of rows?
Yes. Use Rows("5:20").Hidden = False to target rows 5 through 20 only, replacing the numbers with your range.