ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   group sheets with macro in excel (https://www.excelbanter.com/excel-discussion-misc-queries/89303-group-sheets-macro-excel.html)

jannkatt

group sheets with macro in excel
 
Is there a way to easily group worksheets in excel using a macro so that some
function can be performed on all sheets at the same time? I have over 100
sheets and currently have to list each sheet in the macro. This is time
consuming since the sheet names change every year.

Thanks.

Bob Phillips

group sheets with macro in excel
 
Worksheets(Array("Sheet1", "Sheet2")).Select


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"jannkatt" wrote in message
...
Is there a way to easily group worksheets in excel using a macro so that

some
function can be performed on all sheets at the same time? I have over 100
sheets and currently have to list each sheet in the macro. This is time
consuming since the sheet names change every year.

Thanks.




Miguel Zapico

group sheets with macro in excel
 
You may use the Worksheets collection, and loop through it. Something like:

Dim wksPage As Worksheet
For Each wksPage In ActiveWorkbook.Worksheets
'Here you can do whatever you need with the wksPage object
Next

Hope this helps,
Miguel.

"jannkatt" wrote:

Is there a way to easily group worksheets in excel using a macro so that some
function can be performed on all sheets at the same time? I have over 100
sheets and currently have to list each sheet in the macro. This is time
consuming since the sheet names change every year.

Thanks.



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

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