+ Reply to Thread
Results 1 to 7 of 7

Activate workbook without exact name

  1. #1
    Registered User
    Join Date
    05-07-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    15

    Activate workbook without exact name

    Hi all,

    So in my process I am opening 3 workbooks. At the beginning of the macro I want to save the previous "Information MM-DD-YY.xls" as a new workbook "Information MM-DD-YY.xls" using the current date. This is easy using the ActiveWorkbook.Name script but sometimes this isn't the active workbook.

    Is there a way to activate this workbook? I'm having trouble because the dates change. Maybe tell it to search for a workbook using tab names???


    Thanks,
    Street3

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Activate workbook without exact name

    What are the names of the other two workbooks you have open?
    What are the names of the tabs in the workbook you want to save with the current date?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    05-07-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Activate workbook without exact name

    Other two workbooks are "Data.xls" and "Chart.xls"
    There are 9 tabs in the workbook I want to save. The first 3 are "Matrix In," "Matrix Out," and "Sheet1."

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Activate workbook without exact name

    Try this:

    Please Login or Register  to view this content.

    It checks the workbook is NOT one of the other two you have open. Should be faster and more accurate than dealing with worksheet names.

  5. #5
    Registered User
    Join Date
    05-07-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Activate workbook without exact name

    Thanks for the help Dave, but this script is reverting me back to the "Chart.xls" workbook. I might like to use the sheet reference because more than these 3 workbooks may be open at the time. I'll do a google search and see what I come up with.

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Activate workbook without exact name

    The reason for the problem is I should have layered the workbook names like this:

    Please Login or Register  to view this content.
    I misused the AND, sorry.

    This one still stays with the workbook method, but it won't matter how many workbooks you have open, as long as there is only 1 with "Information" in the name.

    Please Login or Register  to view this content.
    Otherwise, if you really want to use the worksheets:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-07-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Activate workbook without exact name

    Thanks Dave works perfectly. Exactly what I needed!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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