View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default find text within string and then delete

Also this

With Sheets("Sheet1")
Set c = .Cells.Find(what:="REPORT", LookIn:=xlValues, lookat:=xlPart)

If Not c Is Nothing Then
firstAddress = c.Address
Do
c.ClearContents
Set c = .FindNext(after:=c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

"Mike H" wrote:

Hi,

This works on column A. Right click your sheet tab, View code and paste this
in and run it.

Sub stance()
Dim MyRange As Range
Lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & Lastrow)
For Each c In MyRange
If InStr(1, UCase(c.Value), "REPORT") Then
c.ClearContents
End If
Next
End Sub

Mike

"scubadiver" wrote:


I want to look for the word 'report' within a larger text string and then
delete all the text in the cell.