+ Reply to Thread
Results 1 to 7 of 7

Select multiple sheets based on a the value of a range name

  1. #1
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Select multiple sheets based on a the value of a range name

    Hi everyone,

    I got a puzzle about using the range name for a worksheet selection. The name PrintWhat_ refers to a cell which has the value:

    "Master", "T1"

    Now I used the code below in the hope of selecting tabs of Master and T1:

    ws = Range("PrintWhat_")
    ThisWorkbook.Sheets(ws).Select

    but this resulted in an run-time error '9'.
    Last edited by billj; 10-05-2015 at 11:36 AM.

  2. #2
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: Select multiple sheets based on a the value of a range name

    Do I really have to split the cell values of "Master", "T1" into two separate cells? So one will be Master, and the other will be T1.

    Hope there is an easy way to do that.

  3. #3
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Select multiple sheets based on a the value of a range name

    You can try this.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by skywriter; 10-05-2015 at 12:17 PM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  4. #4
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: Select multiple sheets based on a the value of a range name

    Hi skywriter, thanks for your kind reply.

    I just want to select all sheets (separated by ",") all together based on the range name of PrintWhat_. For example, if PrintWhat_ is equal to "Master", "T1", then these two sheets will be selected. This will then allow me to do operations from there. How can I do that? Thank you.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Select multiple sheets based on a the value of a range name

    Try this.
    Please Login or Register  to view this content.
    Note, if you didn't use " around the names the Replace wouldn't be required.
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: Select multiple sheets based on a the value of a range name

    Hi, skywriter, i can understand the purpose of the msgbox now. that is exactly what I need. Thank you.

  7. #7
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: Select multiple sheets based on a the value of a range name

    Thanks a lot, Norie.

+ 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. Select Multiple Sheets based on List
    By roasty_1 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-22-2014, 01:36 AM
  2. Select Multiple Sheets Based on Cell Values VBA
    By ZachA3 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-21-2014, 04:32 PM
  3. [SOLVED] Macro that will select range based off cell value in multiple rows
    By hambly in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-09-2013, 03:05 PM
  4. How to select rows based on data in a column off multiple sheets?
    By wdwinterfang in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-20-2013, 11:51 PM
  5. [SOLVED] Macro that will select range based off cell value in multiple rows
    By hambly in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-14-2013, 09:12 AM
  6. [SOLVED] Select Sheets based on variable array -ERROR 9 Subscript out of range
    By airmiles in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2012, 07:28 PM
  7. Replies: 3
    Last Post: 12-02-2010, 03:15 AM
  8. Select sheets based on what is in a range.
    By Steve in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-29-2006, 01:15 PM

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