Global find and replace in entire workbook

merskamp

New Member
Joined
Sep 28, 2005
Messages
47
I can do a find and replace in a worksheet but is there a quick way to apply it to an entire workbook - I have 16 sheets of data and doing a one by one sheet replace is really tedious.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Welcome to the Board!

How's this:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> ReplaceAll()
    <SPAN style="color:#00007F">Dim</SPAN> cursht <SPAN style="color:#00007F">As</SPAN> Worksheet, ws <SPAN style="color:#00007F">As</SPAN> Worksheet
    <SPAN style="color:#00007F">Dim</SPAN> x <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, y <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
    
        <SPAN style="color:#00007F">Set</SPAN> cursht = ActiveSheet
        
        x = InputBox("Replace What?", "Replace What?", ActiveCell.Value)
            <SPAN style="color:#00007F">If</SPAN> x = "" <SPAN style="color:#00007F">Then</SPAN> ReplaceAll
        y = InputBox("Replace With?", "Replace <SPAN style="color:#00007F">With</SPAN>?", ActiveCell.Value)
                
        <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> ws <SPAN style="color:#00007F">In</SPAN> ActiveWorkbook.Worksheets
            <SPAN style="color:#00007F">With</SPAN> ws
                .Activate
                <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN>
                .Cells.Replace _
                    What:=x, _
                    Replacement:=y, _
                    LookAt:=xlPart, _
                    SearchOrder:=xlByRows, _
                    MatchCase:=<SPAN style="color:#00007F">False</SPAN>
            <SPAN style="color:#00007F">End</SPAN> With
        <SPAN style="color:#00007F">Next</SPAN> ws
        
        cursht.Activate
        
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,

Smitty
 
Upvote 0
I can do a find and replace in a worksheet but is there a quick way to apply it to an entire workbook - I have 16 sheets of data and doing a one by one sheet replace is really tedious.
This worked for me:
1. Select all sheets (right-click any sheet tab and choose 'Select All Sheets'.
2. Select all cells (click the 'Cells' box - the grey rectangle to the left of column A heading).
3. Edit|Replace... complete the Find what: and Replace with: boxes|Replace All|Close
4. Right click a sheet tab and choose 'Ungroup Sheets'
 
Upvote 0
Hi, Peter,

good to know that one :-)
I never thought about grouping sheets to replace items

have a nice sunday, you made mine :wink:
Erik

:oops: Australia, your sunday could be over by now
 
Upvote 0

Forum statistics

Threads
1,224,884
Messages
6,181,569
Members
453,053
Latest member
Kiranm13

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