IF - THEN question
Bob,
That's what I was looking for. Thanks a ton!
--
Steve C
"Bob Phillips" wrote:
The cell may be formatted as $0.00, but the value is 0.
And then, if you iterate through a range using an object called cell, you
should use cell, not activecell.
And then, because you are iterating through in a 'look-ahead' type of loop,
there is not need to slect anything.
Sub HidePLRows()
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Range("HideRows")
If cell.Value = 0 And cell.Offset(0, -3).Value = "" Then
cell.EntireRow.Hidden = True
End If
Next
Range("A14").Select
Application.ScreenUpdating = True
End Sub
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"Steve C" wrote in message
...
In my spreadsheet, col. A contains quantities, col. B contains prices. In
column D, I have formulas multiplying quantity times price. Column D
cells
are also formatted as currency, and they display $0.00 when no quantity is
present.
I've named col. D as a range ("HideRows"). My goal is to have my code
search my named range, and for each cell containing $0.00, if the
corresponding quantity cell is empty, hide the row. If the quantity is
entered as zero, I don't want the row to be hidden. My code is below, but
it
is not recognizing my conditions. What am I missing? Thanks for your
help!
Sub HidePLRows()
Dim cell As Range
Application.ScreenUpdating = False
Range("HideRows").Select
For Each cell In Range("HideRows")
If ActiveCell.Value = "$0.00" And ActiveCell.Offset(0, -3).Value = ""
Then
Selection.EntireRow.Hidden = True
Else
ActiveCell.Offset(1, 0).Select
End If
Next
Range("A14").Select
Application.ScreenUpdating = True
End Sub
--
Steve C
|