Thread: Worksheet Tabs
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Worksheet Tabs

Try something like the following. Change the name of the template sheet in
the line marked with <<<<.

Sub AAA()
Dim DT As Date
Dim ws As Worksheet
Dim N As Long
Const TEMPLATE_SHEET_NAME = "TSheet" '<<< CHANGE

On Error Resume Next
DT = CDate(InputBox("Enter start date:"))
On Error GoTo 0
If DT = 0 Then
Exit Sub
End If

Application.ScreenUpdating = False
For N = 1 To 26
With ThisWorkbook.Worksheets
.Item(TEMPLATE_SHEET_NAME).Copy after:=.Item(.Count)
Set ws = ActiveSheet
ws.Name = Format(DT, "mmm dd") & " - " & _
Format(DT + 13, "mmm dd")
DT = DT + 14
End With
Next N
Application.ScreenUpdating = False
End Sub


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"WLMPilot" wrote in message
...
I am trying to create a workbook with 26 sheets (26 - 2 wk scheduling) for
work.
I was wondering if a macro could execute via command button to copy a
template for a two week schedule 26 times AND label the sheet tab with the
date of the payperiod, ie Mar 2 - Mar 15?

If so, what would the code need to be for copy and labeling?

Thanks,
Les