View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Sol Apache Sol Apache is offline
external usenet poster
 
Posts: 8
Default Adding, naming Worksheets sequentially

Belated but many thanks for these macros - Incidental and Mike

Sorry, got involved in something else which has taken up all my time.

Mike's macro works instantly. Still figuring out Incidental's, and learning
more about Excel.

Sol


On 14/3/07 13:15, in article
, "Incidental"
wrote:

You could try something like this also though it's not as nice as
Mikes version

Option Explicit
Dim Ws As Worksheet
Dim i, WsCnt As Integer

Private Sub CommandButton1_Click() ' Rename all existing sheets
i = 1
For Each Ws In Worksheets
Ws.Name = "test" & i
i = i + 1
Next Ws
End Sub

Private Sub CommandButton2_Click() 'Add sheet to end and name it
WsCnt = Worksheets.Count
Sheets.Add After:=Sheets("test" & WsCnt)
ActiveSheet.Name = "test" & WsCnt + 1
End Sub

S