Can you hide an blank if statement?

zilch4ry

Board Regular
Joined
Feb 27, 2011
Messages
76
hi everyone,

right, i have created a pizza order spreadsheet for an ict project and as part of this i have a final order section which shows all of the selections made by the customer. What i really wanted to do was if the quantity of one of the pizzas was set to "1", i wanted only that pizza to be seen in the final order screen, however i couldn't see anyway of doing this. I finally decided to create an if statement which if the quantity was set to 1 then the name of the pizza being ordered would show up and if the quantity was 0 then the cell would be blank using "" as the false answer.

So i guess my question is, "can i hide an entire row if the quantity of a pizza is set to 0, resulting in only pizzas showing in the order table if it has 1 or higher in the quantity cell".

If anybody could explain a way of doing this, it will be hugely appreciated- even if it isn't possible i wouldn't mind knowing either.

thanks in advance,



Tom
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi Tom
Can't be done with a formula. To hide a row based on a condition, you would need to use VBA
Something like this, if any row in column "A" is equal to 0, then the row will be hidden.
Might be a starting point.
Code:
Sub remove()
Dim r As Long, LR As Long, stxt As String	
LR = Cells(Rows.Count, "A").End(xlUp).Row	
        For r = LR To 2 Step -1	
                If Range("A" & r).value = 0 Then	
                    Rows(r).EntireRow.Hidden = True	
                End If	
        Next r	
End Sub
 
Upvote 0
That worked great! Thank you, but what would i add to the end of the code you posted to make the cells re-appear if the quantity is higher than 0?
 
Upvote 0

Forum statistics

Threads
1,224,532
Messages
6,179,388
Members
452,908
Latest member
MTDelphis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top