Replace in sheet vs workbook

  • Thread starter Thread starter Lynn
  • Start date Start date
L

Lynn

I want to include a Replace All in my macro. How do I
specify whether Excel should look within the Workbook or
Sheet? When I record the macro, every other setting is
specified except this one.
 
Lynn,

If you are searching the entire workbook, you need to loop
through each worksheet and run the Replace code on each sheet.
E.g.,

Dim WS As Worksheet
For Each WS In Worksheets
' your replace code here, working on WS
Next WS


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Thanks Chip. This is useful code. Is there a way to force
it to search only the current sheet? A problem I have is
that Excel uses the setting that was selected the last
time someone did a Replace in the workbook. It would be
convenient to force it to look only on the sheet.
 
Back
Top