+ 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
    Excel 2010
    Posts
    10

    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
    2007 | 2013
    Posts
    4,781

    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
    Excel 2010
    Posts
    10

    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
    2007 | 2013
    Posts
    4,781

    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
    Excel 2010
    Posts
    10

    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
    2007 | 2013
    Posts
    4,781

    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)

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