Rename new worksheet with the current date

J

Jeff Parrott

I have a workbook that I do not use every day, but when I use it I need to
copy the contents of the last sheet to a new worksheet and then name the new
sheet with the current date. What I have now is very simple, since the
worksheet I want to copy is always the active sheet I just used the following:

ActiveSheet.Copy After:=ActiveSheet

Now I want to name the new sheet whatever the current date is. Any ideas?
 
D

Don Guillett

Sub copysheetandnamedate()
myname = Format(Date, "mm-dd-yy")
ActiveSheet.Copy After:=ActiveSheet
ActiveSheet.Name = myname
End Sub
 
G

Gord Dibben

After the Activesheet gets copied, the copy now becomes the Activesheet.

ActiveSheet.Copy After:=ActiveSheet
ActiveSheet.Name = Format(Date, "mmddyyyy")


Gord Dibben MS Excel MVP
 
J

Jeff Parrott

Thanks, all of you. I actually sort of used a combination of everything and
came up with:

Sub copysheet()

ActiveSheet.Copy After:=ActiveSheet
ActiveSheet.Name = Format(Date, "mm-dd-yyyy")

End Sub

It works just like I wanted it to. Thanks!
 

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

Top