View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default How to delete cells with a given data?

This little macro will clear any cell that contains "sadness":

Sub MakeHappy()
Dim rr As Range, r As Range
Dim s As String, rClear As Range
Set rr = ActiveSheet.UsedRange
s = "sadness"
For Each r In rr
If InStr(r.Value, s) 0 Then
If rClear Is Nothing Then
Set rClear = r
Else
Set rClear = Union(rClear, r)
End If
End If
Next
If rClear Is Nothing Then
Else
rClear.Clear
End If
End Sub

hopefuly it will make you "happy"!
--
Gary''s Student - gsnu201001


"Teka" wrote:

I'm trying to delete series of cells with a given word inside, but there are
too many to FIND one by one and delete them.