Renaming sheet

  • Thread starter Thread starter Manuel Murieta
  • Start date Start date
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.
 
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
 

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

Back
Top