Is it possible to automaticly name a new sheet 22/10/2003

  • Thread starter Thread starter Marvin Hlavac
  • Start date Start date
M

Marvin Hlavac

Once every day a new worksheet will be added to my workbook and I wonder if
it is possible to automate the process of naming the sheets. I would like
the new sheets to be given the name of the day they were created e.g
22/10/2003.

Is it at all possible.

Thanks in advance.
 
Try naming the sheet with 22/10/2003. It will list the illegal
characters that you can't use.

That said, this will add a sheet and name it.

Sub AddSheet()
Dim wSht as WorkSheet

Set wSht = WorkSheets.Add
wSht.Name = Format(Date, "ddmmyyyy")
End Sub

If you're not familiar with using macros, David McRitchie provides a
good introduction on the subject.

http://www.mvps.org/dmcritchie/excel/getstarted.htm

HTH
Paul
 
Right-mouse click the Excel LOGO near the File menu, select View Code, then
enter this:
Private Sub Workbook_NewSheet(ByVal Sh As Object)
On Error Resume Next
Sh.Name = Format(Date, "mm-dd-yyyy")
End Sub

(sheet names can't have slashes, so I hope dashes will suffice!)
 
Private Sub Workbook_NewSheet(ByVal Sh As Object)
On Error Resume Next
Sh.Name = Format(Date, "mm-dd-yyyy")
End Sub


It works like a charm, thanks a million Bob and Paul.
 
Back
Top