Naming worksheets as the date created


Posted by Pete on September 10, 2001 11:55 PM

To anyone who can help.

Using a macro is there any way to name worksheets the date they were created. So if I created a worksheet on the 12 of September 2001 it would be named "12/9/01" or "9/12/01.

Thanx.

Posted by Chris on September 11, 2001 5:50 AM

From experience I have found that file names cannot be saved with either \ or / in them as they refer to directory structures.

You can however save a file with the full date or any other formatted date you wish by using a string variable to hold that days date and then inserting that variable in place of the filename in VBA code.

Try this

dim DateOfFile as string

DateOfFile = Format(now(), "dd-mm-yy")

ActiveWorkbook.SaveAs Filename:=DateOfFile & ".xls"

obviously you may want to put a filepath in the filename.

Hope this helps.

Chris

Posted by Pete on September 11, 2001 5:49 PM

Sorry Chris I probably didn't make myself clear enough. When I wrote worksheets I was refering to the individual sheets in a work book rather than the file name of the entire work book. I was wondering if there is any way of doing this using a macro.

Thanx.



Posted by . on September 12, 2001 2:44 PM

Sheets.Add.Name = Format(Now(), "dd-mm-yy")