Hide Rows with Zero Value using Macros (VBA) in Excel Office 365!
Tags: hiderowswithzerovalu, vbamacros, macrosvba
Published: 2021-03-05 08:30:27

---
title: Hide Rows with Zero Value using Macros (VBA) in Excel Office 365!
published: true
date: 2021-03-04 07:50:29 UTC
tags: Hiderowswithzerovalu,VBAMacros,MacrosVBA
canonical_url: https://geekexcel.com/hide-rows-with-zero-value-using-macros-vba-in-excel-office-365/
---

In this guide, we will show you the simple steps to **hide rows with zero value using Macros** & [VBA](https://geekexcel.com/excel-office-365-vba-overview-definition-and-examples/) in Excel Office 365. Macros will make your work easy and simple, so you can finish any kind of task with a few clicks. Let’s get into this article, and know the clear-cut steps to achieve this task.

## Hide Rows with Zero Value:

You need to follow the below steps to hide rows that contain zero values.

- For instance, you can see the range of data regarding the student’s mark list in the below screenshot.
- Here, we have shown the student id, name, and marks in the range **A1:C5.** We are going to hide the rows if the student mark is zero.

![Input Range](https://geekexcel.com/wp-content/uploads/2021/03/EXCEL_lqstiIJXsT.png)<figcaption id="caption-attachment-22222">Input Range</figcaption>

- On the **Developer Tab, select** the **Visual Basic** option under the **Code** section.

![Select Visual Basic option](https://geekexcel.com/wp-content/uploads/2020/09/Select-Visual-Basic-option-4.png)<figcaption id="caption-attachment-14755">Select the Visual Basic option</figcaption>

- Then you need to copy and paste the code given below.

VBA code to hide rows using Macros

Sub HideRows()

Set myRange = Application.Selection

Set myRange = Application.InputBox(“Select one Range:”, “HideRows”)

for Each myCell In myRange

If myCell.Value = “0” Then

myCell.EntireRow.Hidden = True

End If

Next

End Sub

- You need to **save the code** by selecting it. Then **close** the **window.**

![Save the code](https://geekexcel.com/wp-content/uploads/2021/03/EXCEL_8yjMtGRHa5.png)<figcaption id="caption-attachment-22227">Save the code</figcaption>

- You have to open the sheet containing the data. On the **Developer Tab, choose** the **Macros option** in the **Code** section.

![Choose the Macros option](https://geekexcel.com/wp-content/uploads/2020/09/Choose-the-Macros-option-2.png)<figcaption id="caption-attachment-14747">Choose the Macros option</figcaption>

- You need to make sure that your macro is selected and **click** the **Run** button.

![Click the Run button](https://geekexcel.com/wp-content/uploads/2021/03/EXCEL_nLnCBrF29u.png)<figcaption id="caption-attachment-22224">Click the Run button</figcaption>

- Then you need to **select the range** and **click** the **OK** button.

![Click the OK button](https://geekexcel.com/wp-content/uploads/2021/03/EXCEL_ZpXlv7FhOJ.png)<figcaption id="caption-attachment-22225">Click the OK button</figcaption>

- At last, you will see that the rows with zero value are hidden as shown in the below screenshot.

![Result](https://geekexcel.com/wp-content/uploads/2021/03/EXCEL_e6afffPx82.png)<figcaption id="caption-attachment-22226">Result</figcaption>

## Closure:

In this guide, you can clearly learn the simple instructions to **hide rows with zero value using Macros**  **&**  **VBA** in Excel Office 365. Drop your **suggestions/feedback** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!

#### Keep Reading:

- [How to Compare Two Ranges using Macros (VBA) in Excel 365?](https://geekexcel.com/how-to-compare-two-ranges-using-macros-vba-in-excel-365/)
- [Deselect Cells from Selected Range using Macros (VBA) in Excel 365!!](https://geekexcel.com/deselect-cells-from-selected-range-using-macros-vba-in-excel-365/)
- [How to Copy a Cell to Clipboard using Macros (VBA) in Excel 365?](https://geekexcel.com/how-to-copy-a-cell-to-clipboard-using-macros-vba-in-excel-365/)