Create new worksheet name with System DateTime

  • Thread starter Thread starter magix
  • Start date Start date
M

magix

Hi,

in Excel VBA coding,
How can I create new worksheet name with System DateTime ? Because I
understand the name can not have some special character like colon :

E.g Let say now is Dec 11, 2005 1:30:29 pm. It needs to put into string
format

So it will be 12112005133029

Something like:

Dim MyDate as String
Dim MyTime as String
MyTime = Time
MyDate = Date

..... after formating
wsNew.Name = MyDate & MyTime

Please help. Thanks.

Regards, Magix
 
Magix,

MyDate = Format(Date, "mmddyyyy")
MyTime = Format(Time, "hhmmss")

Or you could use dashes for readability:

MyDate = Format(Date, "mm-dd-yyyy")
MyTime = Format(Time, "hh-mm-ss")

Earl Kiosterud
www.smokeylake.com
 

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

Back
Top