Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Find and replace If Then ?

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Find and replace If Then ?

If c Like "*insurance company*" then

Unless the user has an Option Compare Text statement in his/her code window,
your test above will be case sensitive. If you want to use the Like
operator, then you could try it this way...

If LCase$(c) Like "*insurance company*" Then

however, I'm thinking this might be better...

If InStr(1, c, "insurance company", vbTextCompare) Then

Rick

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
Find/Replace Event or Find/Replace for Protected Sheet ... Joe HM Excel Programming 2 October 27th 07 03:55 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Using Find and Replace to replace " in a macro snail30152 Excel Programming 1 April 13th 06 11:58 PM
Replace method - cannot find any data to replace Mike Excel Programming 5 April 6th 06 08:56 PM


All times are GMT +1. The time now is 04:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"