Give name of date on a new worksheet

  • Thread starter Thread starter Antonis
  • Start date Start date
A

Antonis

Hello,
I want to create a new worksheet and give it the name of
the date
I use this code but I get error 1004

Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name
= DateValue(Now)

Can you please tell me what I am doing wrong.
I have checked help files and the internet I cant get
working

Thanks for you time.
 
Use this Antonis

Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name _
= Format(Now, "dd-mm-yy h-mm-ss")

Change the format as you like
 
Try this instead of DateValue(Now) :-

Format(DateValue(Now), "YYMMDD")

You can alter the format to suit your needs

Geoff
 
Thanks a lot.

I also found this way if it interests you.

Dim ShName As String
Dim nChr As Integer
ShName = CStr(Date)
' Replace /
For nChr = 1 To Len(ShName)
If Mid(ShName, nChr, 1) = "/" Then Mid(ShName,
nChr, 1) = "-"
Next
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name
= ShName

It is an interesting approach

Thanks again
 
Back
Top