Renaming Tabs in a Macro

L

Liz C

Hi! I have an existing macro that reformats several things on a workheet and
then copies the worksheet to another worksheet in the same book and sorts it
in a different order. I then have to manually rename the two worksheets -
the first one to "20081030 by Name" and the second tab to "20081030 by Loc",
where 20081030 is the date.

What would I add in the macro to change the two tabs automatically to the
current date and "by Name" and the current date and "by Loc"?

Thanks in advance for your help!

Liz
 
L

Liz C

That'll work, but how do I get it to put the current date in the correct
format as part of the name?
 
S

Sheeloo

Sample code to get the date in the desired format
Sub t()
Dim effdate As Long
effdate = Right(Date, 4) & Left(Date, 2) & Mid(Date, 4, 2)
MsgBox effdate
End Sub

My default date format is mm/dd/yyyy
You may have to re-arrange the components if your format is different
MsgBox date will tell you what you have
 

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