macro apply to all worksheet

A

AskExcel

hi,
i have a simple macro to do find and replace but only on the sheet that i
open.
may i know how to make this macro to change all sheets if found the same
string in the workbook?

sub macro()
Cells.Replace What:="C:\xxx\xxx\xxx\", Replacement:="C:\yyy\yyy\yyy\" _
, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat _
:=False, ReplaceFormat:=False
end sub

thanks
 
J

Jacob Skaria

For intSheet = 1 To ActiveWorkbook.Sheets.Count
Sub Macro()
With ActiveWorkbook.Sheets(intSheet)
'Place you code here
..Cells.Replace What:="jacob", Replacement:="jac" _
, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat _
:=False, ReplaceFormat:=False

End With
Next
End Sub

If this post helps click Yes
 
A

AskExcel

Hi,
Thanks for the reply but still only the open sheet is updated only.
I still need to open sheet by sheet to run only can get changed.
I have 50 over sheets and I cannot open every single sheet to get it updated.
Any more advice?
Thanks
 
J

Jacob Skaria

I have tried this with 3 sheets and it works for all 3 even if i am in
Sheet1. Note that there is a period just before cells (.Cells). Paste the
code as such and try changing the text to be searched and replaced.

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top