+ Reply to Thread
Results 1 to 3 of 3

Activate open workbook from range in another workbook

  1. #1
    Forum Contributor
    Join Date
    03-09-2012
    Location
    Isle of Man
    MS-Off Ver
    Excel 2010
    Posts
    118

    Activate open workbook from range in another workbook

    Hi Guys,

    I am working in a workbook (let's call it "Master workbook"). When I run a macro other workbooks are opened and data is collated from them and pasted into the Master Workbook. One of the workbooks that the macro opens is a workbook that is replaced daily. The title of the workbook is a date e.g. OtherWorkbook 01-06-2016.xlsx Because the name of the file changes the macro uses a date in C10 and data in cell D10 of my master workbook to enable me to open the file.

    Cell C10 has the date 01/06/2016 and cell D10 has the formula ="OtherWorkBook "&TEXT(C10,"dd-mm-yyyy")&".xlsx" resulting in D10 containing OtherWorkbook 01-06-2016.xlsx

    When in my Master Workbook the following code opens OtherWorkbook 01-06-2016.xlsx
    Please Login or Register  to view this content.
    Once the information from OtherWorkbook 01-06-2016.xlsx has been copied into my Mater Workbook I want some code to activate OtherWorkbook 01-06-2016.xlsx and close the workbook. How do I write this as VBA code when the name of the file is a date that changes i.e. the name of the file will not always be the same.

    Any help you can give me is much appreciated.

    Thanks

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,354

    Re: Activate open workbook from range in another workbook

    What you should do is use workbook objects in your code, along the lines of this (which also shows how to not use .Select )

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Activate open workbook from range in another workbook

    Hi there,

    See if the following code does what you need:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your own requirements.

    The My Master Worksheet Name worksheet is the worksheet which contains the FileName prefix and the Date cells.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

+ 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. Trying to activate an open Workbook with a variable
    By msf013 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2014, 01:53 PM
  2. macro to copy cells(Range) from an open Workbook to another open Workbook.
    By jbester in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2013, 09:47 AM
  3. Activate another open workbook and sheet
    By DFrank231 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2013, 11:14 AM
  4. [SOLVED] Activate an open workbook
    By jimbolhp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2012, 03:00 PM
  5. Activate Open Workbook
    By Launchnet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2010, 11:42 PM
  6. Activate sheet after open workbook?
    By proepert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2010, 08:22 AM
  7. Need to activate an open workbook
    By TrafficGuy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-06-2008, 04:52 PM
  8. how to Activate the previous Open, workbook..?
    By acegap in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2006, 11:20 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