Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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
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
Macros is several worksheets Lisa Excel Discussion (Misc queries) 3 September 23rd 08 07:34 PM
Macros with Protected Worksheets Terri Excel Discussion (Misc queries) 1 April 13th 06 06:27 PM
Macros and worksheets cinvic Excel Discussion (Misc queries) 2 March 14th 06 04:19 PM
macros affecting different worksheets CJW Excel Discussion (Misc queries) 1 September 2nd 05 04:29 PM
macros across multiple worksheets ... jer Excel Programming 1 November 1st 03 08:54 AM


All times are GMT +1. The time now is 07:13 PM.

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

About Us

"It's about Microsoft Excel"