How do I create/use a sheet template
If you want to insert a new specific worksheet to your workbook with a nice layout and
maybe a few formulas on a regular basis then you have two options.
1) Make a copy each time of a clean worksheet with your layout
Select the sheet that you want to copy
Right click on the sheet tab and choose “Move or Copy”
Check the “Create Copy” checkbox
Be sure that the “To book” dropdown show the name of your file
Press OK
Or hold the CTRL key down and drag the sheet tab to the right or left with your mouse
When you release the mouse button you will see the copy of the sheet.
2) Use a Sheet template
How do I create one:
Open a new workbook and delete all worksheets except the first one.
Change all the things you want in this worksheet
Then use File>Save As to save the file with the name you want as a Template (xlt, in 2007 xltx or xltm)
In this folder (default folder if you save as a template)
Note: Ron is the user name in the path
C:\Documents and Settings\Ron\Application Data\Microsoft\Templates
In Vista you can find the folder here
C:\Users\Ron\AppData\Roaming\Microsoft\Templates
With code you can find the correct path with this line
MsgBox Application.TemplatesPath
How do I insert it in my workbook:
Right click on a sheet tab and choose “Insert”
Select your template
OK
Or you can use a macro to insert the sheet template.
The example below will insert the template MySheetTemplate.xlt after the last
sheet in your workbook with the name: today's date.
You can use this macro if you want to insert a new worksheet based on this template
every day with the date as name.
Sub Insert_Sheet_Template()
Dim sh As Worksheet
Dim shName As String
'name of the sheet template
shName = "MySheetTemplate.xlt"
'Insert sheet template
With ThisWorkbook
Set sh = Sheets.Add(Type:=Application.TemplatesPath & shName, _
after:=.Sheets(.Sheets.Count))
End With
'Give the sheet a name, today's date in this example
On Error Resume Next
sh.Name = Format(Date, "yyyy-mmm-dd")
If Err.Number > 0 Then
MsgBox "Change the name of Sheet : " & sh.Name & " manually"
Err.Clear
End If
On Error GoTo 0
End Sub
If you remove the name part in this macro and the sheet name in the template is "ron" the first time
the name of the sheet is "ron" the second time the name is "ron(1)" and the third time "ron(2)" and .....
With the macro example below you can select the template that you want to insert
Sub Select_The_Sheet_Template()
Dim MyPath As String
Dim SaveDriveDir As String
Dim FileToOpen As Variant
SaveDriveDir = CurDir
MyPath = Application.TemplatesPath
ChDrive MyPath
ChDir MyPath
FileToOpen = Application.GetOpenFilename("Excel Templates (*.xlt*),*.xlt*")
If FileToOpen <> False Then
Sheets.Add Type:=FileToOpen
End If
ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub
Change the default Excel sheet template
In Excel 97-2007 you can insert a new default worksheet like this:
Right click on a sheet tab and click on “Insert” and choose “Worksheet”
Or use the shortcut Shift F11
Or you can use the Excel menu or the ribbon
In Excel 97-2003 you can use “Insert>Worksheet”
In Excel 2007 on the Home tab in the Cells group choose “Insert>Insert sheet” or click
on the “insert worksheet” button next to the last sheet tab
If you want to change the settings of this worksheet you can create your own sheet template.
Open a new workbook and delete all worksheets except the first one.
Change the things you want in this worksheet (Font/background color, font and font size and ?)
Then use File>Save As to save the file as a Template (xlt, in 2007 xltx or xltm) with the
name Sheet in the XLSTART folder.
Every sheet you insert now in a workbook is based on this template.
You can find the Excel startup folder here
Note: this a hidden folder
C:\Documents and Settings\Ron\Application Data\Microsoft\Excel\XLSTART
Or in Vista
C:\Users\Ron\AppData\Roaming\Microsoft\Excel\XLSTART
With code you can find the correct path with this code line
MsgBox Application.StartupPath