Auto hide rows based on 0 value

psrs0810

Well-known Member
Joined
Apr 14, 2009
Messages
1,109
I am not a VBA writer but I came across this code for hiding rows - however the vba needs to be re-ran if I make a change.
I have a down that that will pull in a new set of data for the past 2 years. Off to the right, I am summing the 2 years. What I would like, if that row is 0 I would like for it to be hidden.
If I select a new dropdown, then I would want other rows to be visible/hidden based on the information being pulled.
how do I get the vba to change when the data changes?
Thanks



Sub HideRows()
Application.ScreenUpdating = False
Application.Calculation = xlManual

For Each c In Range("AF8:AF34")
If c.Value = 0 Then Rows(c.Row).Hidden = True
Next

Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Your question is a little confusing (kind of fuzzy on some of the details). It may be helpful to see an example of what this data looks like.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

Please also clarify when the code should be re-run.
Is it when someone manually updates one of the drop-down boxes?
 
Upvote 0

Forum statistics

Threads
1,224,895
Messages
6,181,620
Members
453,057
Latest member
LE102024

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