Renaming sheet

M

Manuel Murieta

I would like a macro that will rename a sheet to today's date. I already
have the date set in A1 as val(today()) so that it doesn't change once the
sheet is copied and viewed another day. Now I would like the macro to name
the sheet as the date. Since the program enters the date as 1/19/07 I have
been renaming the sheet manually as 1-19-07 since the sheet cannot accept
the "/" as part of the name.
 
J

JE McGimpsey

One way:

Public Sub RenameSheetToday()
Dim sName As String
sName = Format(Date, "m-d-yy")
With ActiveSheet
On Error Resume Next
.Name = Format(Date, "m-d-yy")
On Error GoTo 0
If .Name <> sName Then _
MsgBox "Couldn't rename worksheet to '" & sName & "'"
End With
End Sub
 
Top