excel_2009
Active Member
- Joined
- Sep 14, 2009
- Messages
- 318
Hi excel gurus,
I've been working on the following code which works great however it fails to find and replace values that are in a sentence:
For example if AXA exists independently in cell A2 it'll replace however if the value AXA is within a sentence it simply won't replace, any idea why this might be and how to resolve this issue?
Many thanks!!

I've been working on the following code which works great however it fails to find and replace values that are in a sentence:
Code:
Private Sub CommandButton2_Click()
'' Reset
Dim sh As Worksheet, rng As Range
For Each sh In ThisWorkbook.Sheets
Set rng = sh.Range("A:FA")
rng.Replace TextBox1.Value, "AXA", xlWhole, xlByRows, False 'execute the replacement with parameters.
rng.Replace TextBox2.Value, "BXX", xlWhole, xlByRows, False
rng.Replace TextBox3.Value, "BrX", xlWhole, xlByRows, False
rng.Replace TextBox4.Value, "M9X", xlWhole, xlByRows, False
Next
End Sub
For example if AXA exists independently in cell A2 it'll replace however if the value AXA is within a sentence it simply won't replace, any idea why this might be and how to resolve this issue?
Many thanks!!