Thread: Macro If And
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default Macro If And

Try the following macro. I modified yours to take out unnecessary steps and
used a For loop instead of a Do loop. Post back if you need more or if this
doesn't do what you want. Watch out for line wrapping in this message. HTH
Otto
Sub DeleteRows()
Dim rngHTR As Range
Dim i As Range
Set rngHTR = Range("D5", Range("D" & Rows.Count).End(xlUp))
For Each i In rngHTR
If i.Value = "Heater" And IsEmpty(Cells(i.Row, "B").Value) Then _
i.EntireRow.Delete
Next i
End Sub

"Herve_Rob" wrote
in message ...

Hi
anyone to help me on this ?

I have done this macro to delete the rows where in Colomn D = Heater.


Dim HTRCell As Range
Dim rngHTR As Range
Dim rngHTRCell As Range

Do
Set HTRCell = Cells(Rows.Count, "D").End(xlUp)
Set rngHTR = Range("D5", HTRCell)
Set rngHTRCell = rngHTR.Find("Heater")

If rngHTRCell Is Nothing Then
Exit Do
Else
Rows(rngHTRCell.Row).Delete
End If
Loop
End Sub

I would like to modify that condition as:
if D=Heater (as above) *and* B = blank value the delete row D

Regards
Herve


--
Herve_Rob
------------------------------------------------------------------------
Herve_Rob's Profile:
http://www.excelforum.com/member.php...o&userid=35204
View this thread: http://www.excelforum.com/showthread...hreadid=550064