ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a one macro on all sheets within the file (https://www.excelbanter.com/excel-programming/359551-running-one-macro-all-sheets-within-file.html)

Eron

Running a one macro on all sheets within the file
 
Hi All,

I am using excel 2003.

I would like to know if anyone knows how to run one macro on all sheets
within the file.

Today I have a spread sheet with over 100 sheets. In order to receive
the my final outcome I need to run the same macro 100 times (in each
sheet). The macro I am using is an add in macro.

There must be a way i could run a macro that will do the job for me.

I would really appreciate if some one could give me an answer.

Eron


[email protected]

Running a one macro on all sheets within the file
 
Loop through the sheets using something like:

For i = 1 To Worksheets.Count

'Your code here

Next i

HTH,
John


Eron

Running a one macro on all sheets within the file
 
thanks a lot.

sorry for my ignorance, but where do i write this? how do i start a new
macro like this one.

Eron


Tom Ogilvy

Running a one macro on all sheets within the file
 
In your workbook with the 100 sheets you would go to a general module
(Insert Module) and put in the code

Sub Run100()
Dim sh as Worksheet
for each sh in thisworkbook.Worksheets
sh.Activate
application.Run "MyAddinName.xla!MyMacroName"
Next
End sub

Then you would go to Excel and choose

Run100 in Tools=Macros=macro and hit the run button.

Obviously you would change "MyAddinName.xla!MyMacroName" to the name of
the addin and the name of the macro in that addin that you want to run.

--
Regards,
Tom Ogilvy


"Eron" wrote in message
oups.com...
Hi All,

I am using excel 2003.

I would like to know if anyone knows how to run one macro on all sheets
within the file.

Today I have a spread sheet with over 100 sheets. In order to receive
the my final outcome I need to run the same macro 100 times (in each
sheet). The macro I am using is an add in macro.

There must be a way i could run a macro that will do the job for me.

I would really appreciate if some one could give me an answer.

Eron





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

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