convert date to string of numbers

D

D.S.

How would I write a line of code to change the date, such as 02/09/07, to a
string of numbers '020907'

I'm trying to write a line that will "save as" an excel file with a
specific name concatenated with the date at the end. Note: the date will
always change depending on the date the file is saved.

Here's a sample of the line of code I am working with

ActiveWorkbook.SaveAs Filename:= _
' "C:\Temp\SaveAsTest_" & <INSERT DATE CODE HERE> & ".xls",
FileFormat _
' :=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
' False, CreateBackup:=False


ds
 
B

Bob Phillips

I suggest writing the date backwards, helps sorting

ActiveWorkbook.SaveAs Filename:= _
' "C:\Temp\SaveAsTest_" & Format(date,"yy,mmdd") & ".xls",
FileFormat _
' :=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
' False, CreateBackup:=False



--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
D

D.S.

Thanks. While both suggestions will work, < Format(Date,"mmddyy") will work
better for my situation. I'm using a variable for the Date because it's not
actually the current date, rather it's always a date in the past.

ds
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top