Hide rows based on the value of one of their cells

Museau

New Member
Joined
Jun 4, 2017
Messages
4
Hello everyone!

First off, I should start with a big, big thank you: I've spent a few days working on a template to create offers for my catering business, and this website has helped me SO MUCH! However, it seems that I can't make this one work, even by reading other posts:

On the budget page of the offer, I would like to hide all rows where the number of the "d" column (which is the quantity of an item) is "0". So if for instance d4=0, then I'd like to hide the whole d row. Is there an easy way to make this using VBA?

Have a great day!

Museau
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hey Sektor,

Thanks for your answer! I was trying to avoid this and automate the process, is there a way to do this automatically in real time? Or would it slow down the file too much?
 
Upvote 0
Autofilter works much faster comparing to manual hiding.
Of course, you can automate it with VBA. Suppose, you have a range A1:F10 with header. Then the following code will filter out zeros in column D:
Code:
Sub DoFilter()
    'First, remove any filter if it was previously applied.
    ActiveSheet.AutoFilterMode = False
    'Do the filtering.
    'The field number is ALWAYS relative to the range - not the sheet!
    'Column "D" is fourth column relative to A1:F10.
    With Range("A1:F10")
        .AutoFilter Field:=4, Criteria1:=0
    End With
End Sub
 
Upvote 0
Whow thank you so much! It seems to work, but now it only shows the lines where the qty is zero. This is probably a very obvious question but how can I do it so that it HIDES the rows with zero in column D?
 
Upvote 0
Thank you VERY MUCH! That works great and I can keep on working on the rest now. [TABLE="width: 100%, align: center"]
<tbody>[TR]
[TD="bgcolor: #FFFFFF"]Большое спасибо!

[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Большое спасибо!
Not at all!
hi.gif
 
Upvote 0

Forum statistics

Threads
1,223,743
Messages
6,174,244
Members
452,553
Latest member
red83

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