Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Loop through varible list of sheets

Hi all,

I'm trying to get excel to perform a certain macro on each sheet that
has the name of a entry in a list, eg; I have a list of names and all
of these names has their own sheet. This list is on a "Database" sheet
in a certain column. I want to run a macro on all the sheets with one
of those names, but not on my other sheets (which are used for
reporting). I've tried all sorts of loops, but I can not get this to
work

I hope my question is clear,

Thanks in advance and a happy new year!

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default Loop through varible list of sheets

Try this:

Sub test()
Dim shnames As Range
Set shnames = Range("A2:A5") 'adjust sheet name range!
For Each sh In shnames
Sheets(sh.Value).Select
MsgBox sh.Value
Call yourmacro
Next sh
End Sub

Regards,
Stefi


€ť ezt Ă*rta:

Hi all,

I'm trying to get excel to perform a certain macro on each sheet that
has the name of a entry in a list, eg; I have a list of names and all
of these names has their own sheet. This list is on a "Database" sheet
in a certain column. I want to run a macro on all the sheets with one
of those names, but not on my other sheets (which are used for
reporting). I've tried all sorts of loops, but I can not get this to
work

I hope my question is clear,

Thanks in advance and a happy new year!


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Loop through varible list of sheets

Hi Stefi,

It works great! Thanks, the only problem I have is at the end of the
Range, I get a "Subscript out of range" Message...I guess I have to end
the loop somehow?

Thanks again,
Wesley

Stefi wrote:
Try this:

Sub test()
Dim shnames As Range
Set shnames = Range("A2:A5") 'adjust sheet name range!
For Each sh In shnames
Sheets(sh.Value).Select
MsgBox sh.Value
Call yourmacro
Next sh
End Sub

Regards,
Stefi


" ezt írta:

Hi all,

I'm trying to get excel to perform a certain macro on each sheet that
has the name of a entry in a list, eg; I have a list of names and all
of these names has their own sheet. This list is on a "Database" sheet
in a certain column. I want to run a macro on all the sheets with one
of those names, but not on my other sheets (which are used for
reporting). I've tried all sorts of loops, but I can not get this to
work

I hope my question is clear,

Thanks in advance and a happy new year!



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
Automatic Update of Dropdown List Box data Rajat Excel Worksheet Functions 4 March 8th 12 05:09 PM
Data from two sheets make up a list in a third sheet (real time) Vedad Excel Worksheet Functions 1 September 15th 06 03:25 PM
auto updating list Larry Excel Worksheet Functions 8 July 27th 06 01:59 PM
Compare 2 column list across 2 sheets GerryK Excel Worksheet Functions 1 August 23rd 05 05:21 PM
Update master list with other lists Chab Excel Worksheet Functions 0 August 4th 05 03:46 PM


All times are GMT +1. The time now is 07:05 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"