+ Reply to Thread
Results 1 to 3 of 3

How to activate a Workbook that matches the text only

  1. #1
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    How to activate a Workbook that matches the text only

    I have a VBA program that works with multiple Workbooks. I create a new Workbook named ExportTemp.xlsx save it and then switch back to my
    MainWorkbook.xlsm. I label my MainWorkbook with version names like MainWorkbook-120.xlsm.
    Please Login or Register  to view this content.
    Is there a way to activate MainWorkbook-120.xlsm with just:
    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to activate a Workbook that matches the text only

    If your main workbook is the workbook that contains the VBA code, you can refer to it using the ThisWorkbook keyword regardless of its name.

    So...
    ThisWorkbook.Activate
    ..will activate the workbook that contains the code.

    Also, you could assign a workbook variable to the new workbook and use the variable to reference the new workbook.


    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 04-18-2018 at 09:42 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: How to activate a Workbook that matches the text only

    Thanks AlphaFrog! Your assumption is correct, "MainWorkbook" contains the VBA Code.

    Could I not just replace:
    Please Login or Register  to view this content.
    With...
    Please Login or Register  to view this content.
    In my original code to be...
    Please Login or Register  to view this content.

+ 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] Activate Workbook using name in a cell from another workbook
    By Xenthys in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-17-2017, 04:35 AM
  2. [SOLVED] Copy data from Workbook 2 that matches option in Workbook 2
    By Simone Fick in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-09-2017, 08:28 AM
  3. Activate open workbook from range in another workbook
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2016, 10:28 AM
  4. Import graph from a specific workbook if a cell matches the workbook name
    By hassan88 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-29-2015, 05:11 AM
  5. [SOLVED] Change activate workbook to be vba created workbook
    By timtim89 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-18-2012, 09:24 AM
  6. [SOLVED] Workbook.Activate / Window.Activate problem
    By Tim in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-03-2006, 07:40 PM
  7. Replies: 2
    Last Post: 03-21-2005, 08:06 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