Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 19
Default macro apply to all worksheet

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
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default macro apply to all worksheet

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
---------------
Jacob Skaria


"AskExcel" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 19
Default macro apply to all worksheet

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


"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"AskExcel" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default macro apply to all worksheet

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
---------------
Jacob Skaria


"AskExcel" wrote:

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


"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"AskExcel" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apply macro to one sheet only Marcus Analyst Excel Discussion (Misc queries) 9 January 3rd 08 10:14 PM
apply a macro to all sheets except for a certain sheet minrufeng Excel Discussion (Misc queries) 4 February 22nd 06 02:53 PM
automatically apply a macro to all worksheets minrufeng Excel Discussion (Misc queries) 5 February 21st 06 09:34 PM
Not apply macro to every worksheet in activeworkbook G Setting up and Configuration of Excel 2 November 28th 05 05:36 PM
One More Try: Names/Apply on other worksheet Mike Excel Worksheet Functions 3 April 17th 05 09:40 PM


All times are GMT +1. The time now is 03:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"