ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   creating a new worksheet from a template using VBA (https://www.excelbanter.com/excel-programming/375916-creating-new-worksheet-template-using-vba.html)

David Coyle

creating a new worksheet from a template using VBA
 
Hi,

I am having a problem creating a worksheet from a template using a
click-button.

Private Sub cmdNewWorksheet_Click()
Worksheets.Add Befo=Worksheets("Finish")
Worksheets(Worksheets.Count - 1).Name = txtNewWorksheet.Text
txtNewWorksheet.Text = ""
End Sub

I have a template set up, template1.xlt, with a worksheet created in this
called template.

Does anyone have any ideas?

Any help will be much appreciated.

Thank you in advance.



Bob Phillips

creating a new worksheet from a template using VBA
 
You can just use

Sheets.Add Type:= "C:\myTemplate.xlt"

Before seems to fail with this option, but you could move it afterwards.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"David Coyle" <David wrote in message
...
Hi,

I am having a problem creating a worksheet from a template using a
click-button.

Private Sub cmdNewWorksheet_Click()
Worksheets.Add Befo=Worksheets("Finish")
Worksheets(Worksheets.Count - 1).Name = txtNewWorksheet.Text
txtNewWorksheet.Text = ""
End Sub

I have a template set up, template1.xlt, with a worksheet created in this
called template.

Does anyone have any ideas?

Any help will be much appreciated.

Thank you in advance.





David Coyle[_2_]

creating a new worksheet from a template using VBA
 
Thanks!

for some reason, the code worked when i removed the 'work' from 'worksheets'

Private Sub cmdNewSheet_Click()
Sheets.Add Befo=Sheets("Finish"), Type:="C:\template1.xlt"
Sheets(Sheets.Count - 1).Name = txtNewSheet.Text
txtNewSheet.Text = ""
End Sub

Much Appreciated.

"Bob Phillips" wrote:

You can just use

Sheets.Add Type:= "C:\myTemplate.xlt"

Before seems to fail with this option, but you could move it afterwards.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"David Coyle" <David wrote in message
...
Hi,

I am having a problem creating a worksheet from a template using a
click-button.

Private Sub cmdNewWorksheet_Click()
Worksheets.Add Befo=Worksheets("Finish")
Worksheets(Worksheets.Count - 1).Name = txtNewWorksheet.Text
txtNewWorksheet.Text = ""
End Sub

I have a template set up, template1.xlt, with a worksheet created in this
called template.

Does anyone have any ideas?

Any help will be much appreciated.

Thank you in advance.






Bob Phillips

creating a new worksheet from a template using VBA
 
Odd, I tried that and it didn't for me?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"David Coyle" wrote in message
...
Thanks!

for some reason, the code worked when i removed the 'work' from

'worksheets'

Private Sub cmdNewSheet_Click()
Sheets.Add Befo=Sheets("Finish"), Type:="C:\template1.xlt"
Sheets(Sheets.Count - 1).Name = txtNewSheet.Text
txtNewSheet.Text = ""
End Sub

Much Appreciated.

"Bob Phillips" wrote:

You can just use

Sheets.Add Type:= "C:\myTemplate.xlt"

Before seems to fail with this option, but you could move it afterwards.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"David Coyle" <David wrote in message
...
Hi,

I am having a problem creating a worksheet from a template using a
click-button.

Private Sub cmdNewWorksheet_Click()
Worksheets.Add Befo=Worksheets("Finish")
Worksheets(Worksheets.Count - 1).Name = txtNewWorksheet.Text
txtNewWorksheet.Text = ""
End Sub

I have a template set up, template1.xlt, with a worksheet created in

this
called template.

Does anyone have any ideas?

Any help will be much appreciated.

Thank you in advance.









All times are GMT +1. The time now is 08:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com