How do I increment tabs by date in a workbook?

G

Guest

I have a workbook for each day of the month of June. The name in each tab
will be each day of the month. I don;t want to have to rename each tab. I
should be able to let excel update the tabs. HOW?
 
D

Don Guillett

Sub NewWorksheet()
Dim i As Integer
on error resume next
For i = 2 To 31
ActiveWorkbook.Worksheets.Add
ActiveSheet.Name = "Jun" & i
Next i
End Sub
 
D

Don Guillett

Work backwards to not have to sort
Sub mynewsheets()
on error resume next
For i = 31 To 1 Step -1
On Error Resume Next
Sheets.Add.Name = "Jun" & i
Next i
End Sub
 
G

Gord Dibben

Harley

Try this code from Chip Pearson.

Sub NameSheets()
'Chip Pearson Feb 14th, 2007
Dim Ndx As Long
Dim StartMonth As Variant
StartMonth = Application.InputBox(Prompt:="Enter the month number.", Type:=1)
If StartMonth = False Then
Exit Sub
End If
For Ndx = 1 To ActiveWorkbook.Worksheets.Count
ActiveWorkbook.Worksheets(Ndx).Name = Format(DateSerial( _
IIf(StartMonth = 1, Year(Now) + 1, Year(Now)), StartMonth, Ndx), _
"dd mmm yyyy")
Next Ndx
End Sub


Gord Dibben MS Excel MVP
 

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

Top