Thread: Find & Delete
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Find & Delete

Hi Mike
try the following:

Sub find_delete()
Dim rng As Range
Dim cell As Range
Application.ScreenUpdating = False
Set rng = Selection
For Each cell In rng
If InStr(cell.Value, "msn.com") Then
cell.ClearContents
End If
Next
Application.ScreenUpdating = True
End Sub


Deletes all cells with the string 'msn.com' within your selection


--
Regards
Frank Kabel
Frankfurt, Germany

Mike wrote:
Hi. I am trying to create a macro that will search a
spreadsheet for a certain string. For each cell that
contains this string, I would like to delete the contents
of the cell.

For instance, if the string were "msn.com", I would
expect the following text strings to be found and the
cell values set to be null: ,
, and .

Any suggestions?

Thanks,
Mike.