### Description:

We are required to Hide-UnHide the rows in some types of requirements. For examples we may have data for 3 different categories of items and we may want to show the respective items based on selection. In this case we can achieve by Hiding or Un-hiding the Rows. We will see this in the following examples:

- Hide-UnHide Rows in Excel Worksheet using VBA – An Example
- Hide-UnHide Rows in Excel Worksheet using VBA – Case study
- Hide-UnHide Rows in Excel Worksheet using VBA – Download Example Files
- Hiding Rows with Criteria in Excel Worksheet using VBA – Example File

### Hide UnHide Rows in Excel Worksheet using VBA – Solution(s):

You can use EntireRow.Hidden property of Row. If you set hidden property TRUE, it will hide the rows. Or if you set it to FALSE then it will make rows to visible.

##### Hide-UnHide Rows in Excel Worksheet using VBA – An Example

The following example will show you how to Hide and Unhide the rows in excel worksheet using VBA. We can Hide or Unhide the multiple rows at a time. In this example I am hiding and Unhiding Rows 5 to 8.

###### Code:

Sub sbHidingUnHideRows() 'To Hide Rows 5 to 8 Rows("5:8").EntireRow.Hidden = True 'To UnHide Rows 5 to 8 Rows("5:8").EntireRow.Hidden = False End Sub

###### Instructions:

- Open an excel workbook
- Press Alt+F11 to open VBA Editor
- Insert a Module for Insert Menu
- Copy the above code and Paste in the code window
- Save the file as macro enabled workbook
- Press F5 to run it

###### Output:

Here is the example screen-shot. You can download the file below and see the code. Hide button will call the procedure to hide the rows and unhide button will unhide the rows. For example, Food Button will show you the data and charts related to food. And ‘Show All’ button will show you all categories and ‘Hide All’ button will hide all categories.

### Hide-UnHide Rows in Excel Worksheet using VBA – Case study

Here is the example case study. You can download the file below and see how its working. You can click on the buttons to view the respective data.

### Hide-UnHide Rows in Excel Worksheet using VBA – Download Example File

You can download the example file and see the code for each button.

ANALYSISTABS – Hide-Unhide Rows

## Hiding Rows based on a Condition

Let us assume we have 500 rows/records in a worksheet, we can loop through each row and check for a criteria and hide the rows. Let us see the verity of example with different criteria:

### Hide all rows with the text data /strings in Column A

The following example will hide all all rows with the text data /strings in Column A.

LastRow = 500 'Let's say you have 500 rows in the data For i = 1 To LastRow 'Now we loop through each row and check for required criteria 'To hide all the rows with the text data /strings in Column A If IsNumeric(Range("A" & i)) = False Then Rows(i).EntireRow.Hidden = True Next

### Hide all rows with the values as 0 in Column A

The following example will hide all all rows with the values as 0 in Column A.

LastRow = 500 'Let's say you have 500 rows in the data For i = 1 To LastRow 'Now we loop through each row and check for required criteria 'to hide all the rows with the values as 0 in Column A If Range("A" & i) = 0 Then Rows(i).EntireRow.Hidden = True Next

### Hide all rows with the negative values in Column A

The following example will hide all all rows with the negative values in Column A.

LastRow = 500 'Let's say you have 500 rows in the data For i = 1 To LastRow 'Now we loop through each row and check for required criteria 'to hide all the rows with the negative values in Column A If IsNumeric(Range("A" & i)) = True Then If Range("A" & i) < 0 Then Rows(i).EntireRow.Hidden = True End If Next

### Hide all rows with the Positive values in Column A

The following example will hide all all rows with the Positive values in Column A.

LastRow = 500 'Let's say you have 500 rows in the data For i = 1 To LastRow 'Now we loop through each row and check for required criteria 'to hide all the rows with the Positive values in Column A If IsNumeric(Range("A" & i)) = True Then If Range("A" & i) > 0 Then Rows(i).EntireRow.Hidden = True End If Next

### Hide all rows with the Even Number in Column A

The following example will hide all all rows with the Even Number in Column A.

LastRow = 500 'Let's say you have 500 rows in the data For i = 1 To LastRow 'Now we loop through each row and check for required criteria 'To hide all the rows with the Even Number in Column A If IsNumeric(Range("A" & i)) = True Then If Range("A" & i) Mod 2 = 0 Then Rows(i).EntireRow.Hidden = True End If Next

### Hide all rows with the Odd Number in Column A

The following example will hide all all rows with the Odd Number in Column A.

LastRow = 500 'Let's say you have 500 rows in the data For i = 1 To LastRow 'Now we loop through each row and check for required criteria 'To hide all the rows with the Odd Number in Column A If IsNumeric(Range("A" & i)) = True Then If Range("A" & i) Mod 2 = 1 Then Rows(i).EntireRow.Hidden = True End If Next

### Hide all rows if the value in Column A is greater than 50

The following example will hide all all rows if the value in Column A is greater than 50.

LastRow = 500 'Let's say you have 500 rows in the data For i = 1 To LastRow 'Now we loop through each row and check for required criteria 'To hide all the rows if the value in Column A is greater than 50 If IsNumeric(Range("A" & i)) = True Then If Range("A" & i) > 50 Then Rows(i).EntireRow.Hidden = True End If Next

### Hide all rows if the value in Column A is less than 100

The following example will hide all all rows if the value in Column A is less than 100.

LastRow = 500 'Let's say you have 500 rows in the data For i = 1 To LastRow 'Now we loop through each row and check for required criteria 'To hide all the rows if the value in Column A is less than 100 If IsNumeric(Range("A" & i)) = True Then If Range("A" & i) < 100 Then Rows(i).EntireRow.Hidden = True End If Next Next

# Premium Project Management Templates

# 50+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

**PREMIUM TEMPLATES**

LIMITED TIME OFFER

LIMITED TIME OFFER

**ON SALE80% OFF**

50+ Project Management Templates Pack

Excel PowerPoint Word

Ultimate Project Management Template – Advanced

Excel Template

ULTIMATE PROJECT MANAGEMENT TEMPLATE

Excel Template

20+ Excel Project Management Pack

Excel Templates

20+ PowerPoint Project Management Pack

PowerPoint Templates

10+ MS Word Project Management Pack

Word Templates