Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default worksheet template


Hi,

I want to use a ws as a template (used many times). What is the code
to create a copy of the template ws and rename it using a string
variable?

The template has a fair bit of formatting, so I presume this method is
better than creating new sheets and having the code format each new
sheet?

kind regards,
Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default worksheet template


Use the Sheets.Add method...
Sheets.Add befo=Sheets(1), Count:=1,Type:= _
"C:\Documents and Settings\MJKelly\Application Data\Microsoft\Templates\Timecard.xlt"
--
Jim Cone
Portland, Oregon USA



"MJKelly"
wrote in message
Hi,
I want to use a ws as a template (used many times). What is the code
to create a copy of the template ws and rename it using a string
variable?
The template has a fair bit of formatting, so I presume this method is
better than creating new sheets and having the code format each new
sheet?
kind regards,
Matt
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default worksheet template

Try this from Dave Peterson.

Sub CreateNameSheets()
' by Dave Peterson
' List sheetnames required in col A in a sheet: List
' Sub will copy sheets based on the sheet named as: Template
' and name the sheets accordingly

Dim TemplateWks As Worksheet
Dim ListWks As Worksheet
Dim ListRng As Range
Dim myCell As Range

Set TemplateWks = Worksheets("Template")
Set ListWks = Worksheets("list")
With ListWks
Set ListRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each myCell In ListRng.Cells
TemplateWks.Copy After:=Worksheets(Worksheets.Count)
On Error Resume Next
ActiveSheet.Name = myCell.Value
If Err.Number < 0 Then
MsgBox "Please fix: " & ActiveSheet.Name
Err.Clear
End If
On Error GoTo 0
Next myCell

End Sub


Gord Dibben MS Excel MVP

On Wed, 17 Sep 2008 14:44:25 -0700 (PDT), MJKelly
wrote:


Hi,

I want to use a ws as a template (used many times). What is the code
to create a copy of the template ws and rename it using a string
variable?

The template has a fair bit of formatting, so I presume this method is
better than creating new sheets and having the code format each new
sheet?

kind regards,
Matt


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Template worksheet wcurtis Excel Discussion (Misc queries) 0 January 2nd 09 04:54 PM
Template question - can I replace the default "worksheet" template Jackie Excel Discussion (Misc queries) 2 April 19th 06 11:59 AM
Can I add a new worksheet using a template John[_115_] Excel Programming 2 March 30th 06 03:58 PM
Worksheet-template (HELP!) at_a_loss Excel Programming 1 February 26th 06 09:40 PM
Worksheet template Phippsy Excel Worksheet Functions 2 November 11th 05 10:13 AM


All times are GMT +1. The time now is 04:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"