+ Reply to Thread
Results 1 to 4 of 4

Setting a collection of worksheets to feed to a For Each loop

  1. #1
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Setting a collection of worksheets to feed to a For Each loop

    I can get a For Each loop to go through all worksheets in my workbook but how can I limit the loop to a subset or just a collection of worksheets? What I need to do should not be done on all my worksheets.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,153

    Re: Setting a collection of worksheets to feed to a For Each loop

    e.g.:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Setting a collection of worksheets to feed to a For Each loop

    Please Login or Register  to view this content.
    You can also use an array of sheets

    For Each wks In Worksheets(Array("A", "B", "C"))

    Next

    This loop applies to the sheet names, A, B and C and any other sheet name in the sheet collection will be ignored.
    Last edited by AB33; 10-18-2017 at 03:46 PM.

  4. #4
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Re: Setting a collection of worksheets to feed to a For Each loop

    Thanks, both of these with slight modifications can work to solve my problem....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 03-21-2017, 02:38 PM
  2. Using a For each loop with a column collection
    By DaProStudent in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-16-2017, 01:15 PM
  3. Replies: 4
    Last Post: 10-30-2015, 01:30 PM
  4. [SOLVED] For loop through Worksheets collection
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-31-2014, 08:23 AM
  5. Need Help With Setting Series Collection Width Using VBA
    By PosseJohn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2013, 01:48 PM
  6. Loop through worksheets setting formula in cells
    By JonPugh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-20-2010, 09:02 AM
  7. Help With Basic Feed Back Loop
    By STAPLER2 in forum Excel General
    Replies: 2
    Last Post: 11-05-2008, 02:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1