+ Reply to Thread
Results 1 to 3 of 3

Using a path with a variable filename

  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    6

    Post Using a path with a variable filename

    I have a folder that gets updated with excel sheets a few times a week. The files are in the format that follows:

    \\snj1afsfs16\investmentm$\Daily_Transaction_Files\AXA Transactions Summary mm dd yyyy.xls

    I would like to tell my macro to open the file that matches with a function giving today's date "=Workday(Today(),-1)" that I inserted in excel in cell B12 let's say. If the macro can't find the file for that date (which happens), then I'd like a Messagebox to pop up stating that it couldn't find any transactions for today's date. How would I do so?

    Please help! I just started with VBA and truly need some help!

    Cheers

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

    Re: Using a path with a variable filename

    Try something like this...

    Please Login or Register  to view this content.
    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 Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Using a path with a variable filename

    Make sure the date in B12 is formatted correctly.

    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

+ 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] How to extract filename from path\filename
    By mpan in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-05-2013, 11:23 PM
  2. [SOLVED] Find if filename exists and update variable within the filename structure
    By Lungfish in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 03-18-2013, 02:42 AM
  3. Macro to copy from xls( variable filename) to static xls filename
    By gsp77 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-11-2012, 09:33 AM
  4. Replies: 3
    Last Post: 07-09-2012, 03:09 PM
  5. Find filename, path, document size, filename length and path length?
    By Laneyboggs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2010, 08:01 PM

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