Running a macro on all sheets in a file

  • Thread starter Thread starter Eron
  • Start date Start date
E

Eron

Hi all,

Today I have a spreadsheet that contains 100 different sheets in it. In
my module I have to run a macro in each sheet in order to recieve the
final outcome.

Is there a way I could run one macro that will run on all the sheets at
once, instead of what I am doing today which is to log into each sheet
and run the macro.
 
Hi all,

Today I have a spreadsheet that contains 100 different sheets in it. In
my module I have to run a macro in each sheet in order to recieve the
final outcome.

Is there a way I could run one macro that will run on all the sheets at
once, instead of what I am doing today which is to log into each sheet
and run the macro.

You have posted this message to the wrong newsgroup.
The access in this groups name refers to Microsoft Access, a database
program.
Please repost to the Excel version you are using. I would suggest you
include your Windows and Office version number in the message.
 
Eron said:
Hi all,

Today I have a spreadsheet that contains 100 different sheets in it. In
my module I have to run a macro in each sheet in order to recieve the
final outcome.

Is there a way I could run one macro that will run on all the sheets at
once, instead of what I am doing today which is to log into each sheet
and run the macro.
Hi Eron, Fred is correct...

Something that you can consider is to cycle through the collection of
worksheets.

dim xlBook as excel.workbook
dim xlWsh as excel.worksheet
dim xlRng as excel.range
'xlBook is an object variable set to the active workbook in the excel
application
'you post made no mention of problem referencing these so not included in
example
for each xlWsh in xlBook.worksheets
with xlWsh
'code for this worksheet
set xlRng=xlWsh.range("A1")
....
end with
doevents
next xlWsh


Luck
Jonathan
 
Hey Jonathan,

I guess I have posted this query in the wrong group. I appriciate your
help. I will try this.

Thanks a ton,

Eron
 
Back
Top