+ Reply to Thread
Results 1 to 5 of 5

Find sheet name in another workbook based on name from one workbook

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Thumbs up Find sheet name in another workbook based on name from one workbook

    Hi all,
    I have to workbooks, one for our data and one from our source. Both workbooks have sheets that are numerically named 1 through 58 and other sheets that don't really matter to me. What I need to do is: If our data workbook is on sheet "1", I want to activate the source workbook and find sheet "1". And then do that from 1 to 58. I need this done by name though and not sheet sequence because sheet "1" is actually located on Sheet4. Does this make sense?
    Last edited by Mordred; 09-02-2010 at 02:38 PM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find sheet name in another workbook based on name from one workbook

    Hi Mordred

    Here's one way to do as you described
    Please Login or Register  to view this content.
    The code assumes both workbooks are in the same folder, that Data is open and that Source is closed. The code opens Source then closes it without saving.

    The code will reside in a general module in Data.

    Hope this helps.

    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Find sheet name in another workbook based on name from one workbook

    Hi John,
    Thank you for that. I think it needs to be tweaked a bit but you've got me going in the right direction.
    On the second iteration of this code
    Please Login or Register  to view this content.
    a Run time error "Subscript out of range" is thrown but I might be able to correct it (at least, I'll try). I appreciate your insight.

    Regards,

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find sheet name in another workbook based on name from one workbook

    Hi Mordred

    You'll get this message
    "Subscript out of range"
    if the sheet name doesn't exist. You'll need to check the sheet names to make certain they are named the same.


    EDIT Just tried this and it didn't work

    You might try changing these two lines of code
    Please Login or Register  to view this content.
    in the event your sheet names have leading blanks.

    John
    Last edited by jaslake; 09-02-2010 at 02:37 PM.

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Find sheet name in another workbook based on name from one workbook

    Hi John,
    I realized that while trying to figure it out. I put the code into a mock copy of my original but I only have one sheet name numerically. Your suggestion works perfectly and I thank you for your time.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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