How do I name tabs with dates for the rest of the year?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am looking to be able to name tabs with individual days (November 9,
November 10 etc.) for the rest of the year without having to type each tab
title. Is there a way to do this? I have looked online in several places but
have not found an answer.
 
One way with that VBA macro:

Option Explicit
Sub testme01()

Dim iCtr As Long
Dim FirstDate As Date
Dim LastDate As Date
Dim myName As String
Dim wks As Worksheet

FirstDate = Date 'dateserial(2004,11,09) 'for a specific date
LastDate = DateSerial(Year(FirstDate), 12, 31)

On Error Resume Next
For iCtr = FirstDate To LastDate
myName = Format(iCtr, "mmmm dd")
Set wks = Worksheets.Add(after:=Worksheets(Worksheets.Count))
wks.Name = myName
If Err.Number <> 0 Then
'MsgBox "oh, oh with: " & myName
Beep
Err.Clear
Application.DisplayAlerts = False
wks.Delete
Application.DisplayAlerts = True
End If
Next iCtr
On Error GoTo 0
End Sub
If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

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