+ Reply to Thread
Results 1 to 6 of 6

Macros to save with a filename and date from cell

  1. #1
    Registered User
    Join Date
    01-31-2012
    Location
    Australia
    MS-Off Ver
    OFFICE 365
    Posts
    34

    Macros to save with a filename and date from cell

    I have set up a fuel logging spreadsheet with a button. I am trying to write a macro that will then save my spreadsheet to my D drive with a default name and date from a specific cell.

    i.e the file name is "Edwinas Fuel Log". I want the file to save to my "D" drive with the file name "Edwinas Fuel Log - dd-mmm-yyy". This date would be retrieved from cell B4 on the spreadsheet.

    My apologies if i am not explaining myself properly but I have tried all sorts of things but everything comes back with an error and its' driving me crazy.

    Any help would be very much appreciated.

    Thanks in advance

    Paul

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: Macros to save with a filename and date from cell

    Hi Paul

    Try this...
    Change red to your path
    Blue to sheet housing date in [B4]
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    01-31-2012
    Location
    Australia
    MS-Off Ver
    OFFICE 365
    Posts
    34

    Re: Macros to save with a filename and date from cell

    Hi Sintek, thanks for your help, I have been struggling with this for some time to no avail.

    I have changed a couple of details but when I run the macro I get a "Run-Time error 424 - Object required" message.

    I changed the name of the file to "Edwina - EOM Fuel Figures.xls" The name of worksheet is "EDWINA-EOM" and the cell reference for the date is now "B3". I would like it to save to D:\

    The debugging process highlights the line FileName = "D:\" & "Edwina - EOM Fuel Figures - " & Format(EDWINA - EOM.Range("B3"), "dd-mm-yyyy") but for the life of me I do not know what I am doing wrong

    This is the macro in my file:

    Sub Save_File()
    Dim FileName As String
    FileName = "D:\" & "Edwina - EOM Fuel Figures - " & Format(EDWINA - EOM.Range("B3"), "dd-mm-yyyy")
    ThisWorkbook.SaveAs FileName & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
    End Sub
    Last edited by pvwebster; 07-14-2018 at 07:05 AM.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: Macros to save with a filename and date from cell

    Paul !!!

    In future please view the forum rules before posting. Your post does not comply with rule #3.
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing.
    So, do the following:
    Edit your post, highlight your code and click the [#] button at the top of the post window.
    Must be more to your path than just "D:\"

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-31-2012
    Location
    Australia
    MS-Off Ver
    OFFICE 365
    Posts
    34

    Re: Macros to save with a filename and date from cell

    Thanks Sintek, that worked perfectly.

    My apologies for not following the rules, it wasn't intentional but I will be more mindful next time.

    Thanks again for your help. I couldn't have completed this without your help

    Regards

    Paul

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: Macros to save with a filename and date from cell

    ........................................
    Thanks.gif

+ 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] pdf save and send (date range filename)
    By COYF in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2018, 10:45 AM
  2. Save Copy Filename As Without Including Macros
    By mudajaya in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2016, 02:52 AM
  3. [SOLVED] Save Filename as Date
    By Krayvok in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2015, 02:49 AM
  4. Replies: 0
    Last Post: 08-09-2012, 04:31 PM
  5. [SOLVED] Save Filename With Date In It
    By timbo1957 in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 05-20-2011, 08:08 AM
  6. Save xls with date appended to end of filename
    By mattmac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2008, 06:41 AM
  7. [SOLVED] Date + Filename using save copy as
    By SKelley in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2005, 05: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