Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Create a new sheet in a workbook from a template

In my last question I was looking for a way to check or uncheck a tick box to insert or remove a new sheet in a workbook.
I know I can create a new workbook based on an excel template file, can I combine these two steps and set the macro below to create a new worksheet, based on a template, in the existing workbook?
Previous macro was

Public Sub CheckBox1_Click()
Const sSHEETNAME As String = "My New Sheet"
On Error Resume Next
With ActiveSheet
If .CheckBoxes(Application.Caller).Value = xlOn Then
With Worksheets.Add(After:=Sheets(Sheets.Count))
.Name = sSHEETNAME
.Range("A1").Value = "Related Text"
End With
.Select 'Restore selection to calling sheet
Else
Application.DisplayAlerts = False
Worksheets(sSHEETNAME).Delete
Application.DisplayAlerts = True
End If
End With
On Error GoTo 0
End Sub

--
Roger W
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Create a new sheet in a workbook from a template

If you use sheets.add, you can specify your own template:

With Sheets.Add(After:=Sheets(Sheets.Count), _
Type:="C:\WINDOWS\Application Data\Microsoft\Excel\XLSTART\sheet.xlt")

.....

RogerNZ wrote:

In my last question I was looking for a way to check or uncheck a tick box to insert or remove a new sheet in a workbook.
I know I can create a new workbook based on an excel template file, can I combine these two steps and set the macro below to create a new worksheet, based on a template, in the existing workbook?
Previous macro was

Public Sub CheckBox1_Click()
Const sSHEETNAME As String = "My New Sheet"
On Error Resume Next
With ActiveSheet
If .CheckBoxes(Application.Caller).Value = xlOn Then
With Worksheets.Add(After:=Sheets(Sheets.Count))
.Name = sSHEETNAME
.Range("A1").Value = "Related Text"
End With
.Select 'Restore selection to calling sheet
Else
Application.DisplayAlerts = False
Worksheets(sSHEETNAME).Delete
Application.DisplayAlerts = True
End If
End With
On Error GoTo 0
End Sub

--
Roger W


--

Dave Peterson

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
Making a macro on a template update with new each new sheet create Michelle D[_2_] Excel Discussion (Misc queries) 0 August 10th 09 04:53 PM
Create, name, open, and enter data in new sheet - from template Ann~ Excel Discussion (Misc queries) 6 January 8th 07 11:59 PM
quickly create extra copies of a worksheet template in a workbook simon Excel Worksheet Functions 2 October 23rd 05 07:04 PM
new sheet created 'on the fly' from template in same workbook - H. MrT Excel Worksheet Functions 3 April 10th 05 08:30 PM
Best way to create a workbook template that allows data entry and purchase order req to be created from it Cheryl[_2_] Excel Programming 0 April 29th 04 02:01 PM


All times are GMT +1. The time now is 08:05 PM.

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

About Us

"It's about Microsoft Excel"