Thread: Next in Series
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leo Heuser[_2_] Leo Heuser[_2_] is offline
external usenet poster
 
Posts: 111
Default Next in Series

Howard

Here's one way to do it:

Sub AddSheet()
'Leo Heuser, 20 Oct. 2003
Dim LastSheet As Worksheet
Dim SheetName As String

With ActiveWorkbook
Set LastSheet = .Worksheets(.Worksheets.Count)
SheetName = LastSheet.Name
.Worksheets.Add after:=LastSheet
ActiveSheet.Name = LastSheet.Name + 1
End With
End Sub


--
Best Regards
Leo Heuser
Excel MVP

Followup to newsgroup only please.

"Howard" skrev i en meddelelse
...
Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can add a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF