I need to write a Macro that when run will hide rows

Occasional Visitor

I am creating an order form for a small business.  The form has all of the items available to purchase.  When an employee works on an order for a customer, they will put a quantity in the "Quantity" cell. 


I want the macro to hide any row that has a quantity of "0".


This is my first attempt at writing Macros, so please be very specific.  The screen shot is of the order form as it is currently designed.


2 Replies



I have non-macro solution for your, I would suggest you convert that entry data into Excel Tables & insert the slicer for qty. When generating invoice select all and once you are done with your entry filter out the qty 0 unselect it.


Hope you find this solution helpful and easy.


Regards, Faraz Shaikh 

Hi, If you are still looking for a VBA solution, just change "For i = 17 To 27" to the appropriate row numbers for your range that you want to hide row with a 0 in column J. 



Sub HideRows()

Dim i As Integer

For i = 17 To 27

If Cells(i, 10).Value = 0 Then

Rows(i).EntireRow.Hidden = True

End If

Next i

End Sub

Sub UnHideRows()

Rows.EntireRow.Hidden = False

End Sub 


Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
PacketMon Components are not loading in WAC 1909
HotCakeX in Windows Admin Center on
2 Replies