hide row 5 if a zero in cell D5

G

Guest

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
 
D

Don Guillett

try
if range("d5")=0 then rows(5).hidden=true

--
Don Guillett
SalesAid Software
(e-mail address removed)
btk said:
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top