+ Reply to Thread
Results 1 to 3 of 3

Select Differing Number of Sheets Dynamically

Hybrid View

  1. #1
    Registered User
    Join Date
    12-02-2020
    Location
    Salem, VA
    MS-Off Ver
    2019
    Posts
    10

    Select Differing Number of Sheets Dynamically

    I'm using a macro to select all sheets in a workbook and apply formatting. The number of sheets varies though (could be 3 one day and 10 the next). As long as there are 6 sheets, the code below works. How could I change this to select all sheets, regardless of how many sheets are in the workbook?


    screenshotmacro.png

    Along the same lines, I select all sheets and consolidate the data into a single sheet in a different file. I'm not sure how to do this in a way that allows me to consolidate the data from all sheets, regardless of the names of the sheets and regardless of the number of sheets in the workbook.

    screenshotmacro.png

  2. #2
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,481

    Re: Select Differing Number of Sheets Dynamically

    To answer your first question, this single line of code will select all of the sheets in the active workbook...
    Sheets(Evaluate("TRANSPOSE(ROW(1:" & Sheets.Count & "))")).Select

  3. #3
    Registered User
    Join Date
    12-02-2020
    Location
    Salem, VA
    MS-Off Ver
    2019
    Posts
    10

    Re: Select Differing Number of Sheets Dynamically

    Thank you! That worked perfectly!

+ 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. [SOLVED] Select Unknown Number of Sheets
    By CraigMcKee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-30-2018, 04:30 AM
  2. Macro to dynamically select and copy data from different sheets and columns
    By Gr8tDaze in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2013, 07:32 PM
  3. Replies: 0
    Last Post: 04-22-2012, 06:08 PM
  4. [SOLVED] Run Time Errors Select method of Range Class Failed - Differing Locations
    By Cardinalbags in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-31-2012, 02:41 PM
  5. Replies: 1
    Last Post: 09-10-2010, 01:52 AM
  6. Calculating the number of days within differing years
    By Aardvark MarG in forum Excel General
    Replies: 2
    Last Post: 06-16-2009, 06:46 PM
  7. Replies: 7
    Last Post: 10-18-2007, 11:03 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