Find and replace across multiple worksheets not working fully

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:

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!!

:)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,666
Messages
6,120,806
Members
448,990
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top