+ Reply to Thread
Results 1 to 5 of 5

Using Workbook.Open Filename to Open a Cell Reference Filename

  1. #1
    Registered User
    Join Date
    09-27-2008
    Location
    New Jersey
    Posts
    6

    Using Workbook.Open Filename to Open a Cell Reference Filename

    I am trying to get a file to open as a function of a macro where the filename needs to be dynamic by date. There is no option to change how the reference file is saved, so the file with the macro has a cell with a formula that does this: ="\\server\subserver\folder\subfolder\subsubfolder"&"\ParentFile"&TEXT(TODAY(),"MM")&"_"&TEXT(TODAY(),"DD")&"_"&TEXT(TODAY(),"YY")&".xlsm" But I cannot get that to work in the VBA code...it errors out.

    Need to open the file using that reference... Not married to the Workbook.Open Filename code, but it's what I know...

    Any help is greatly appreciated.

    Mel.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Using Workbook.Open Filename to Open a Cell Reference Filename

    Workbook.Open is the way to do this in VBA. Show the VBA code that you are trying to use (the whole Sub, not just one line), and tell us what error you are getting.

    By the way, be aware that you can do this instead of stringing together several functions and strings:

    TEXT(TODAY(),"MM\_DD\_YY")
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-27-2008
    Location
    New Jersey
    Posts
    6

    Re: Using Workbook.Open Filename to Open a Cell Reference Filename

    Thanks Jeff - No, I didn't know I could do that... Thanks - I adjusted that formula...

    Here is the exact code that I would like to get to work:

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    Please Login or Register  to view this content.
    But the "TODAY" give me a "compile error - sub or function not defined" - hence why I wanted to switch to using the cell reference since the cell works.

    Thanks.
    Last edited by 6StringJazzer; 06-10-2014 at 11:57 AM.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Using Workbook.Open Filename to Open a Cell Reference Filename

    There are two ways to do this: reference the cell with your formula, or build the corresponding VBA. Your VBA is close.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-27-2008
    Location
    New Jersey
    Posts
    6

    Re: Using Workbook.Open Filename to Open a Cell Reference Filename

    Thank you very much!! The first way was what I was going for initially, but could not get to work and moved on to the 2nd...then posted here. Works perfectly now.

    Thank you very much!
    Melissa

+ 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. Workbook.Open Filename procedure
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-16-2010, 10:30 PM
  2. set filename to <filename-date> on open
    By bob engler in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-13-2006, 12:15 AM
  3. Activating an Open Workbook without using the whole filename as a reference
    By jlejehan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2006, 02:58 AM
  4. Open filename using workbook property
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2006, 09:25 PM
  5. [SOLVED] Copy from one workbook to another-Workbooks.Open Filename
    By Alen32 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-03-2005, 10:06 AM

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