This tutorial explains how to unhide one or more rows in Excel using VBA.
You can download the following dataset to practice.
Syntax to Unhide a Row
This code Rows("row number").Hidden = False
unhides the particular row.
1. Unhide a Row
In this example we will try to unhide the 5th row of a given data set.
Sub UnhideSingleRow() Dim ws As Worksheet Set ws = ThisWorkbook.ActiveSheet ws.Rows(5).Hidden = False End Sub
Press Run or F5 to run the above code.
2. Unhide Multiple Rows
We want to unhide all the rows that are arranged continuously (one after another). The following code unhides rows from 5 to 7.
Sub UnhideMultipleRows() Dim ws As Worksheet Set ws = ThisWorkbook.ActiveSheet ws.Rows("5:7").Hidden = False End Sub
Press Run or F5 to run the above code.
3. Unhide Specific Rows
Let's unhide 3rd, 5th and 7th row of a given data set. To do this we take an array that stores the specific row numbers and then with the help of For Each loop we can apply ThisWorkbook.ActiveSheet.Rows(rowNum).Hidden = False
on each row number.
Sub UnhideSpecificRows() Dim ws As Worksheet Dim rowNum As Variant Set ws = ThisWorkbook.ActiveSheet For Each rowNum In Array(3, 5, 7) ws.Rows(rowNum).Hidden = False Next rowNum End Sub
Press Run or F5 to run the above code.
Share Share Tweet