View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Delete row of cells in range based on condition

Try this. Notice the dot placement

Sub deletepartofrowif()
With Sheets("Daily Report")
Set rng = .Range("DA20:DE29")
For Each c In rng
If c = "Rock Breaking" then
.Range(.Cells(c.Row, "da"),.Cells(c.Row, "de")).ClearContents
End If
Next c
End With
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Kirsty" wrote in message
...
I have written this to delete the row of cells within the selected range
when
the value "Rock Breaking" is in a cell in the row.

It is however deleting the entire row.
How do I stop this?


Sub tmp3()

Dim rngOfData As Range
Dim Cell As Range

With Sheets("Daily Report")
Set rngOfData = .Range("DA20:DE29")
End With

For Each Cell In rngOfData
If Cell.Value = "Rock Breaking" Then
Cell.Row.Delete
End If
Next Cell

End Sub