Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hello:
I have a macro in a workbook that I've created on the first worksheet. I have 11 worksheets in the workbook and the same macro needs to run on each worksheet. Is there a way to do it automatically in the original macro or do I have to run it every time separately on each worksheet. Please help. Thank you. Monika |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You can use the macro on other sheets also assuming it does not worksheet
level code/procedures... Steps: Press ALT-F11 to open the VB Editor Choose Insert-Module and paste your macro Now paste the following after changing testmacro to the name of your macro sub runOnAllSheets for each ws in worksheets call testmacro next ws end sub ------------------------------------- Pl. click ''''Yes'''' if this was helpful... "murkaboris" wrote: Hello: I have a macro in a workbook that I've created on the first worksheet. I have 11 worksheets in the workbook and the same macro needs to run on each worksheet. Is there a way to do it automatically in the original macro or do I have to run it every time separately on each worksheet. Please help. Thank you. Monika |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Say we have a macro that does stuff on a single sheet (the ActiveSheet)
Sub SingleSheet() ActiveSheet.Range("A1").Value = "hello world" End Sub We want this done on ALL sheets. So we use a loop: Sub AllTheSheets() Dim s As Worksheet For Each s In Worksheets s.Range("A1").Value = "hello world" Next End Sub -- Gary''s Student - gsnu200844 "murkaboris" wrote: Hello: I have a macro in a workbook that I've created on the first worksheet. I have 11 worksheets in the workbook and the same macro needs to run on each worksheet. Is there a way to do it automatically in the original macro or do I have to run it every time separately on each worksheet. Please help. Thank you. Monika |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hello Sheeloo:
Thank you for your help. Monika "Sheeloo" wrote: You can use the macro on other sheets also assuming it does not worksheet level code/procedures... Steps: Press ALT-F11 to open the VB Editor Choose Insert-Module and paste your macro Now paste the following after changing testmacro to the name of your macro sub runOnAllSheets for each ws in worksheets call testmacro next ws end sub ------------------------------------- Pl. click ''''Yes'''' if this was helpful... "murkaboris" wrote: Hello: I have a macro in a workbook that I've created on the first worksheet. I have 11 worksheets in the workbook and the same macro needs to run on each worksheet. Is there a way to do it automatically in the original macro or do I have to run it every time separately on each worksheet. Please help. Thank you. Monika |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thank you for your help Gary
Monika "Gary''s Student" wrote: Say we have a macro that does stuff on a single sheet (the ActiveSheet) Sub SingleSheet() ActiveSheet.Range("A1").Value = "hello world" End Sub We want this done on ALL sheets. So we use a loop: Sub AllTheSheets() Dim s As Worksheet For Each s In Worksheets s.Range("A1").Value = "hello world" Next End Sub -- Gary''s Student - gsnu200844 "murkaboris" wrote: Hello: I have a macro in a workbook that I've created on the first worksheet. I have 11 worksheets in the workbook and the same macro needs to run on each worksheet. Is there a way to do it automatically in the original macro or do I have to run it every time separately on each worksheet. Please help. Thank you. Monika |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combine worksheets in multiple workbook in one workbook with a macro | Excel Discussion (Misc queries) | |||
Apply Macro to all worksheets in a workbook except one | Excel Discussion (Misc queries) | |||
automatically apply a macro to all worksheets | Excel Discussion (Misc queries) | |||
Excel should apply names in all worksheets of a workbook | Excel Discussion (Misc queries) | |||
apply cell names to formulas in multiple worksheets | Excel Worksheet Functions |