+ Reply to Thread
Results 1 to 11 of 11

VBA Save w/ date showing Wrong Date

  1. #1
    Registered User
    Join Date
    04-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    22

    VBA Save w/ date showing Wrong Date

    I am trying to safe a file including todays date. The macro will exacute, but the date is wrong and strung together
    i.e. Vendor Validation Report 40644.xls \

    I have tried using & Format(NOW, MM - DD - YY) & ".xls", as well as & Format(Date, MM - DD - YY) & ".xls"

    niether seem to pull the correct date or format it in "MM-DD-YY" format

    Any Tips - I am very new to VBA

    thanks


    You can View my code below:

    Sub SAVE_TEST()
    '
    ' SAVE_TEST Macro
    '
    '
    '

    ChDir "C:\~VENDOR_VALIDATION"
    ActiveWorkbook.SaveAs Filename:= _
    "C:\~VENDOR_VALIDATION\Vendor Validation Report" & Format(Date, MM - DD - YY) & ".xls", FileFormat:=xlExcel8, _
    Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
    CreateBackup:=False

    With ActiveSheet
    Range("A1").Select
    End With

    End Sub

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA Save w/ date showing Wrong Date

    hi,
    try this
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Registered User
    Join Date
    04-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: VBA Save w/ date showing Wrong Date

    Nope that doesnt work either. it generate's the same bogus date.....

  4. #4
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: VBA Save w/ date showing Wrong Date

    HI,


    You should use the forum format for the code tags.
    Here is your code which i added a correction too.
    You can however record a macro to see how to format the SaveAs file.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by Charles; 04-11-2011 at 04:03 PM. Reason: corrected code to shorter code
    Charles

    There are other ways to do this, this is but 1 !
    Be Sure you thank those who helped.
    IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.

  5. #5
    Registered User
    Join Date
    04-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: VBA Save w/ date showing Wrong Date

    These do not work, I have tried so many variations, but none of them work. I am using Excel 2007, could this be part of the issue?

    In addition, nobody has included the code for the file extention type. and if I dont script the excel format type (i.e. 97-2003 or 2007) it will save but I loose all the formatting on save and when I open it kicks me a warning that the file is not in the format of its listed extention....

  6. #6
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: VBA Save w/ date showing Wrong Date

    Hi,

    It might help if we can see a copy of your workbook. All of the codes that were posted worked.

  7. #7
    Registered User
    Join Date
    04-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: VBA Save w/ date showing Wrong Date

    I have attached the Workbook I am attempting to save with the current date, and I attached the PERSONAL.XLS that houses all the code. Hope this helps
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: VBA Save w/ date showing Wrong Date

    Hi,

    The following is the code I used for my test.

    Please Login or Register  to view this content.
    This is the result
    Copy of North Vendor Validation Report 04 - 13 - 2011

    Try the following code in your Personal code Module7

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: VBA Save w/ date showing Wrong Date

    I completly belive it is working on other machines, but not only have I tried this exact script, I retried it and still it doesnt work, it kicks this invalid dummy date. Is this a problem with my excel system referance?

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA Save w/ date showing Wrong Date

    hi CBG,
    it works for me too! just for a test, run with this code and see if it works for you with a test file.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    04-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: VBA Save w/ date showing Wrong Date

    John:

    That worked, Why is it that this code worked and none of the other variations did?

    Thanks for the help everyone...

    Brad

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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