Home

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

Sparke0930
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.

2018-12-22.png

2 Replies

Hi,

 

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 

Highlighted

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
38 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies