ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find and Replace across all Spreadsheets (https://www.excelbanter.com/excel-programming/358128-find-replace-across-all-spreadsheets.html)

Plumdodge

Find and Replace across all Spreadsheets
 
I am familar with the Access model, but I know nothing of Excel. How would
write a macro to find/replace and have it loop through every sheet in a
workbork? The number of sheets would be varialbe in all cases, but the values
for find/replace would be fixed.

Also as a side note how would I
select all Columns, then "right-size" to fit?

Thanks a ton!

Jim Thomlinson

Find and Replace across all Spreadsheets
 
Here is the find / replace code for you.

Sub ReplaceEverywhere()
Dim wks As Worksheet

For Each wks In Worksheets
wks.Cells.Replace What:="This", _
Replacement:="That", _
LookAt:=xlValues, _
MatchCase:=False
Next wks
End Sub

Try recording a macro for the Autofit and see what you get...
--
HTH...

Jim Thomlinson


"Plumdodge" wrote:

I am familar with the Access model, but I know nothing of Excel. How would
write a macro to find/replace and have it loop through every sheet in a
workbork? The number of sheets would be varialbe in all cases, but the values
for find/replace would be fixed.

Also as a side note how would I
select all Columns, then "right-size" to fit?

Thanks a ton!



All times are GMT +1. The time now is 04:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com