View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default Find and replace If Then ?

On 13 Jan., 03:15, Office_Novice
wrote:
Here is what I haveCells.Replace What:="Insurance *Company Insurance Policy #
RBH26374", Replacement:= _
* * * * "Insurance Policy - Insurance Company", LookAt:=xlPart,
SearchOrder:= _
* * * * xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

What i need is ...

If the words insurance company appears i need to replace them with *
"Insurance Policy - Insurance Company" is this possible?


Dim tRange as range
Sub ReplaceIf
set tRange=Range("A1:C10") ' Change to suit

For Each c in tRange
If c Like "*insurance company*" then
c.Value = "Insurance Policy - Insurance Company"
End If
Next
End Sub

Regards,

Per