YasserKhalil
Well-known Member
- Joined
- Jun 24, 2010
- Messages
- 852
Hello
I have the following code that I use to replace some text with a nother
If I want to replace for example (John Smith) with (Axel Smith)... There is no problem
But I found that the text (Johny Smith) is replaced with (Axely Smith) .. This is the problem.>>> I want to keep Johny as it is but replace just John
I have the following code that I use to replace some text with a nother
Code:
Sub Replacement()
Dim LastRow As Long
LastRow = Sheets("Conditions").Cells(Rows.Count, "A").End(xlUp).Row
For x = 1 To LastRow
Cells.Replace What:=Sheets("Conditions").Range("A" & x), Replacement:=Sheets("Conditions").Range("B" & x), _
Lookat:=xlPart, SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:= _
False, ReplaceFormat:=False
Next x
End Sub
If I want to replace for example (John Smith) with (Axel Smith)... There is no problem
But I found that the text (Johny Smith) is replaced with (Axely Smith) .. This is the problem.>>> I want to keep Johny as it is but replace just John