View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Code to create and name a sheet

Hi StargateFan,

Try:

'=============
Sub NewSheet_Add()
Worksheets("TEMPLATE").Copy Befo=Worksheets(1)
With ActiveSheet
.Name = Replace(.Name, "TEMPLATE", "Summary")
End With
Worksheets(1).Visible = xlSheetVisible
End Sub
'<<=============


---
Regards,
Norman



"StargateFan" wrote in message
...
On Fri, 30 Dec 2005 18:15:45 -0600, "Chip Pearson"
wrote:

Try

Worksheets.Add.Name = "Summary"


What a neat idea.

What if we have code like this that copies a worksheet rather than
just adds a blank new one:

Sub NewSheet_Add()
Worksheets("TEMPLATE").Copy Befo=Worksheets(1)
Worksheets(1).Visible = xlSheetVisible
End Sub



I get sheets named TEMPLATE (2), TEMPLATE (3), TEMPLATE (4), etc., as
the name of the sheet being copied is called TEMPLATE.

Is there a way to get the code to name the sheets to, say, "Summary -
" as well? Having them come out as Summary - (2), Summary - (3),
Summary - (4), ..., would be just fine. The user would customize by
adding additional date info needed on the tab name - this would just
save them that time and remembering naming format.

Thanks! :oD

Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"dogpigfish" wrote in
message
...
What code can I use to create a new sheet and call it
"Summary".