In this guide, we will show you the simple steps to hide rows with zero value using Macros & VBA 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.
- On the Developer Tab, select the Visual Basic option under the Code section.
- 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.
- You have to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.
- You need to make sure that your macro is selected and click the Run button.
- Then you need to select the range and click the OK button.
- At last, you will see that the rows with zero value are hidden as shown in the below screenshot.
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. Keep Learning!
Top comments (0)