+ Reply to Thread
Results 1 to 2 of 2

Need a better way to direct macro to File Path

  1. #1
    Registered User
    Join Date
    06-24-2016
    Location
    Pittsburgh
    MS-Off Ver
    2013
    Posts
    7

    Need a better way to direct macro to File Path

    I am working on writing a macro that will compile a file and save it to a specified location. The issue I am running into is the format of the file path. Currently I have the macro reading the file path from a formula hidden in a worksheet. The user updates month and year which through a CONCATENATE formula, will give the file path. How can I setup my code to take me to the below folder without referencing my formula? Also, this file will be run in the following month (Dec 2016 file will be run early in January 2017). Also, I need the file name to save with the date and year. That format can be Dec 2016, 12.2016, or December 2016.

    File Path: HFM Monthly Closing\2016\12 December 2016\08 Miscellaneous BU Analysis\2016

    Dim FName As String
    Dim FPath As String

    FPath = "\\J:Finance\CONTROLLERSHIP\BUFin&Consolidation\HFM Monthly Closing\" & Sheets("Worksheet").Range("D6")
    FName = Sheets("Worksheet").Range("D7").Text
    Workbooks.SaveAs Filename:=FPath & FName & ".xlsm"

    Thanks!

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Need a better way to direct macro to File Path

    I'll assume the cell D6 also contains the terminating '\' for the file path?

    I can't really think what you mean by "setup my code to take me to the below folder without referencing my formula" - but it might be useful to know that referencing a cell without specifying which property you want will return the default property. For a cell, this is the VALUE property. If the cell contains a date you will get the underlying value (a number - today is 52729, or something like that). If you want to use the date as displayed in the cell you can use the TEXT property.

+ 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] Save file as macro-enabled with path and file name from a cell
    By BRISBANEBOB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-12-2015, 11:51 PM
  2. Macro to save sheet as CSV using a dynamic file name and file path
    By chris.tinta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2013, 10:45 AM
  3. Macro Relative File Path Help
    By Centexcel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-21-2013, 09:21 AM
  4. Formulas that direct you through a path
    By Dreamwine59 in forum Excel General
    Replies: 2
    Last Post: 12-17-2008, 07:25 PM
  5. Run a .bat file from a macro (using a relative path)
    By titus.hanke in forum Excel General
    Replies: 2
    Last Post: 12-03-2008, 10:28 AM
  6. Have script, works with P:\ (drive letter), not with \\server\folder\ (direct path)
    By AdamParker in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-14-2008, 06:03 PM
  7. How to direct a path name in VBA
    By crieken in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2008, 02:44 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