ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   run a macro for all sheets (https://www.excelbanter.com/excel-programming/356461-run-macro-all-sheets.html)

Bwoods

run a macro for all sheets
 
I recorded a macro that i use to format a sheet. I would like to use this
same macro on multiple sheets without having to select each one and then
running the macro.

thanks in advance

Paul B

run a macro for all sheets
 
Bwoods, use something like this,

Sub Test()
Dim ws As Worksheet
For Each ws In Worksheets
With ws

'Change to your code
.Range("A1").Interior.ColorIndex = 6

End With
Next ws
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Bwoods" wrote in message
...
I recorded a macro that i use to format a sheet. I would like to use this
same macro on multiple sheets without having to select each one and then
running the macro.

thanks in advance




L. Howard Kittle

run a macro for all sheets
 
Here's a loop I got from Tom O. just yesterday

Sub CodeForEachSheet()
Dim WS_Count As Integer
Dim I As Integer

WS_Count = ActiveWorkbook.Worksheets.Count
Application.ScreenUpdating = False
For I = 1 To WS_Count
Worksheets(I).Activate

' Your code here

Next I
Worksheets(1).Activate
Application.ScreenUpdating = True
End Sub

HTH
Regard,
Howard

"Bwoods" wrote in message
...
I recorded a macro that i use to format a sheet. I would like to use this
same macro on multiple sheets without having to select each one and then
running the macro.

thanks in advance




davesexcel[_79_]

run a macro for all sheets
 

http://tinyurl.com/r6mfz

and

http://tinyurl.com/mpq2d

These are the answers for yo

--
davesexce
-----------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...fo&userid=3170
View this thread: http://www.excelforum.com/showthread.php?threadid=52409


Bwoods

run a macro for all sheets
 
That did the TRICK!!!! This will save me a ton of time!

"L. Howard Kittle" wrote:

Here's a loop I got from Tom O. just yesterday

Sub CodeForEachSheet()
Dim WS_Count As Integer
Dim I As Integer

WS_Count = ActiveWorkbook.Worksheets.Count
Application.ScreenUpdating = False
For I = 1 To WS_Count
Worksheets(I).Activate

' Your code here

Next I
Worksheets(1).Activate
Application.ScreenUpdating = True
End Sub

HTH
Regard,
Howard

"Bwoods" wrote in message
...
I recorded a macro that i use to format a sheet. I would like to use this
same macro on multiple sheets without having to select each one and then
running the macro.

thanks in advance





Tom Ogilvy

run a macro for all sheets
 
Didn't see anything pertinent to the questions asked. Sure you posted this
in the correct thread. Unless you meant run it on each sheet manually which
the OP said he/she didn't want to do.

--
Regards,
Tom Ogilvy


"davesexcel" wrote
in message ...

http://tinyurl.com/r6mfz

and

http://tinyurl.com/mpq2d

These are the answers for you


--
davesexcel
------------------------------------------------------------------------
davesexcel's Profile:

http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=524090





All times are GMT +1. The time now is 11:49 PM.

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