Create a new sheet in excel named by date

July 1, 2010 at 11:25:48
Specs: Windows XP
I have a button on a spread sheet that I want an operator to click on at the start of the day and have it make a new sheet with the current day as the name of the new sheet.

Sheets("04-01-10").Copy After:=Sheets(2)
ActiveSheet.Move _
ActiveSheet.Name = "Today()"

That is my code thats tied to the macro button. I tried the change the activesheet.Name without the "" but all i get is errors. Please help.

See More: Create a new sheet in excel named by date

Report •

July 1, 2010 at 11:45:32
Well, there are a couple of issues...

First, Today() isn't available in VBA. It's "equivalent" is Date.

Not Date(), but just Date

However, if you tried ActiveSheet.Name = Date, you'd get errors because Date would return something like this:


Since you can't have / in a sheet name, that would throw up an error.

You could get away with this:

ActiveSheet.Name = Month(Date) & "-" & Day(Date) & "-" & Year(Date)

Report •

July 2, 2010 at 07:43:27
Thank you that worked great.

Report •

July 2, 2010 at 08:14:47
Glad to have helped!

Report •

Related Solutions

Ask Question