hide row 5 if a zero in cell D5

B

btk

To All

The code below is copied from a reply (by Frank Kabel) to a previous post. It hides all rows with a zero in column D

Sub hide_rows(
Dim RowNdx As Lon
Dim LastRow As Lon

LastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Ro
For RowNdx = LastRow To 1 Step -
If Cells(RowNdx, "D").Value = 0 The
Rows(RowNdx).Hidden = Tru
End I
Next RowNd
End Su

Does anyone know how to re-write the code to hide row 5 if a zero is in cell D5

Thanks,
btk
 
A

AlfD

Hi!

Try

Sub hide_row5()

If range("D5").Value = 0 Then Rows(5).Hidden = True

End Sub

Al
 
F

Frank Kabel

Hi
try
sub hide_5()
if activesheet.range("d5")=0 then
rows(5).hidden=true
end if
end sub
 
D

Dave Peterson

A non-macro approach:

Data|filter|autofilter.

Use a custom filter, does not equal 0.
 
Top