View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default Button to copy sheet, rename sheet sequencially.

Option Explicit

Public Sub AddSheets()
Dim ws As Worksheet
Set ws = Worksheets("template")
ws.Copy Worksheets(1)
SetSheetName Worksheets(1)
End Sub
Private Sub SetSheetName(ws As Worksheet)
On Error Resume Next
Dim sname As String
Dim index As Long
index = 0
Do
Err.Clear
index = index + 1
sname = "template" & Format$(index, "000")
ws.Name = sname
Loop While Err.Number < 0
End Sub

"foxgguy2005" wrote:


I have a Setup sheet, which has a button to creat a new sheet, which
actually copies a tamplet. When i click this button it calls the new
tab "Tamplet (2)"
Is there a sub i can put in the copy routine to auto-rename the tabs
sequencially?
Note number of tabs is based upon how many times the user clicks the
new page button.

Thanks!
~Josh


--
foxgguy2005
------------------------------------------------------------------------
foxgguy2005's Profile: http://www.excelforum.com/member.php...o&userid=23663
View this thread: http://www.excelforum.com/showthread...hreadid=378885