Forum Discussion
DnGr
Apr 10, 2025Brass Contributor
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
- DnGrBrass Contributor
Thanks for your help. I believe I have what I need.
Thank you
- DnGrBrass 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.
The Value2 property treats dates as numbers, so use .Value or .Text instead of .Value2
- DnGrBrass 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")
That should add the date as a date, not as a number...
In a formula:
="nameofdocument "&TEXT(TODAY(), "m/d/yyyy")
In VBA:
"nameofdocument " & Format(Date, "m/d/yyyy")