Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macros for worksheets
Hi Metallo
You can use a array if you know the names of the 10 sheets For Each sh In Sheets(Array("Sheet1", "Sheet3")) Then, I have a second question, You can store the macro in your personal.xls file but for only 10 workbooks I think I add the macro to each workbook -- Regards Ron de Bruin http://www.rondebruin.nl "Metallo" wrote in message ... Hi, I have a workbook that contains 15 worksheets and I want to create 2 macros that apply a different formatting to 10 of the worksheets only. I created 2 buttons in a Macro sheet added to the WorkBook and when I have clicked the buttons they do apply the formatting to all the 15 worksheets plus the macro sheet as well. I presume this is due to the fact that I recorder the macro to be applied to this specific workbook, but I cannot find a possibility to apply it only to specific worksheets. Then, I have a second question, what's the best way to apply the same macro to 10 additional workbooks who only differ from the one described because have different values? Thank you Alex |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macros for worksheets
You must copy the macro in a module of the workbook that you send.
Here is a example for making the font of the range bold in each sheet in the array. Read this page first http://www.mvps.org/dmcritchie/excel/getstarted.htm See David McRitchie's site if you just started with VBA Sub test() Dim sh As Worksheet Application.ScreenUpdating = False For Each sh In Sheets(Array("Sheet1", "Sheet2")) sh.Select sh.Range("a1:c10").Font.Bold = True Next Sheets(1).Select Application.ScreenUpdating = False End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Metallo" wrote in message ... Ron, can you better explain how to use the array function, I'm not familiar with it. The workbooks have to be distributed to other people, would it work on their PC if I put the macros on my personal.xls? Thank you Alex "Ron de Bruin" wrote: Hi Metallo You can use a array if you know the names of the 10 sheets For Each sh In Sheets(Array("Sheet1", "Sheet3")) Then, I have a second question, You can store the macro in your personal.xls file but for only 10 workbooks I think I add the macro to each workbook -- Regards Ron de Bruin http://www.rondebruin.nl "Metallo" wrote in message ... Hi, I have a workbook that contains 15 worksheets and I want to create 2 macros that apply a different formatting to 10 of the worksheets only. I created 2 buttons in a Macro sheet added to the WorkBook and when I have clicked the buttons they do apply the formatting to all the 15 worksheets plus the macro sheet as well. I presume this is due to the fact that I recorder the macro to be applied to this specific workbook, but I cannot find a possibility to apply it only to specific worksheets. Then, I have a second question, what's the best way to apply the same macro to 10 additional workbooks who only differ from the one described because have different values? Thank you Alex |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macros is several worksheets | Excel Discussion (Misc queries) | |||
Macros with Protected Worksheets | Excel Discussion (Misc queries) | |||
Macros and worksheets | Excel Discussion (Misc queries) | |||
macros affecting different worksheets | Excel Discussion (Misc queries) | |||
macros across multiple worksheets ... | Excel Programming |