Forum Discussion

DnGr's avatar
DnGr
Brass Contributor
Apr 10, 2025
Solved

Date_in_VBA

Is there a way I can save date so that the date does not come across a number.  I have =today() which gives me the days date.  For example, if I save 4/9/2025.  The document returns with "nameofdocument"45766.  I want it to save the document as "nameofdocument"4/9/2025(the actual date the document is created.  Is this possible?

  • Thanks for your help.  I believe I have what I need.

    Thank you

  • DnGr's avatar
    DnGr
    Brass Contributor

    Thanks for your help.  I believe I have what I need.

    Thank you

  • DnGr's avatar
    DnGr
    Brass Contributor

    I get the debug message.  In my code fName = "PWS_Equipment_" & .Range("G10") & Range("C3").Value2

    I will get the name of the document plus a number.  C3 is where the current date is.  I want C3 to be listed as a date next to the name of the document.  When I added the & Format(Date, "m/d/yyyy") at the end of the VBA code all I get is a debug error.

  • DnGr's avatar
    DnGr
    Brass Contributor

    I added the code at the end.  I am sure I am something incorrect as it did not work.

    This is how I typed it

    fName = "PWS_Equipment_" & .Range("G10") & Range("C3").Value2 & Format(Date, "m/d/yyyy")

  • In a formula:

    ="nameofdocument "&TEXT(TODAY(), "m/d/yyyy")

    In VBA:

    "nameofdocument " & Format(Date, "m/d/yyyy")

Resources