VBA Code for hiding rows with zero value then hiding when value changes

jones987

New Member
Joined
May 2, 2016
Messages
2
Hello,
Would anyone be able to give me a code for hiding rows 17:39 if the value in column D is zero, then unhide if the value changes to greater than zero?
Thank you
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
How are these values changing? From direct input or from a formula causing the change.
 
Upvote 0
If the values in Column (D) rows (17:39) are being changed by direct input then you can use the below script.
If the values are changing due to formula values changing then my knowledgebase has no answer for you. It turns into a on calculation event that then gets complicated for me.

To install this code:

Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D17:D39")) Is Nothing Then
If Target.Value = "0" Then Rows(Target.Row).Hidden = True Else Rows(Target.Row).Hidden = False
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,589
Messages
6,120,415
Members
448,960
Latest member
AKSMITH

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