Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Run a macro on multiple worksheets?

Say I have a macro that reverses the order of a list. I have the identical
list in 5 sheets in a workbook. I tried to select all the sheets and running
the macro, but it only runs it on the worksheet I'm looking at.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Run a macro on multiple worksheets?


For Each sh In Sheets(Array("Sheet1", "Sheet2",
"Sheet3","Sheet4","Sheet5"))
myMacro sh
Next sh

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"J@Y" wrote in message
...
Say I have a macro that reverses the order of a list. I have the identical
list in 5 sheets in a workbook. I tried to select all the sheets and

running
the macro, but it only runs it on the worksheet I'm looking at.



  #3   Report Post  
Posted to microsoft.public.excel.misc
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Run a macro on multiple worksheets?

I'm new to scripting, what exactly is "sh" and "myMacro?

"Bob Phillips" wrote:


For Each sh In Sheets(Array("Sheet1", "Sheet2",
"Sheet3","Sheet4","Sheet5"))
myMacro sh
Next sh

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"J@Y" wrote in message
...
Say I have a macro that reverses the order of a list. I have the identical
list in 5 sheets in a workbook. I tried to select all the sheets and

running
the macro, but it only runs it on the worksheet I'm looking at.




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Run a macro on multiple worksheets?

sh is a variable which can be left undeclared but better is to declare as
type Worksheet

Dim sh As Worksheet

myMacro is the macro that you said that you have.

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"J@Y" wrote in message
...
I'm new to scripting, what exactly is "sh" and "myMacro?

"Bob Phillips" wrote:


For Each sh In Sheets(Array("Sheet1", "Sheet2",
"Sheet3","Sheet4","Sheet5"))
myMacro sh
Next sh

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my

addy)

"J@Y" wrote in message
...
Say I have a macro that reverses the order of a list. I have the

identical
list in 5 sheets in a workbook. I tried to select all the sheets and

running
the macro, but it only runs it on the worksheet I'm looking at.






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
display 1 line of multiple worksheets into multiple lines on 1 wks Golf Nut Excel Worksheet Functions 1 October 5th 06 08:28 AM
Import multiple text files (Macro) Thr33of4 Excel Discussion (Misc queries) 0 September 19th 06 02:19 AM
Display data from multiple worksheets' cells in one worksheet J! Excel Worksheet Functions 1 August 29th 06 08:53 PM
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Functions across multiple worksheets starlight Excel Worksheet Functions 0 August 10th 05 05:10 PM


All times are GMT +1. The time now is 12:14 AM.

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"