ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding new worksheet BEFORE 1st worksheet (https://www.excelbanter.com/excel-programming/427262-adding-new-worksheet-before-1st-worksheet.html)

Rob P

Adding new worksheet BEFORE 1st worksheet
 
I am calling several macros

the last of which is:

Sub summary()
Sheets.Add.Name = "1 day moves"
Sheets.Add.Name = "3 day moves"
End Sub

this inserts the 2 new worksheets BEFORE the very last sheet

how can I insert these BEFORE a specific worksheet called "template"

thank you
Rob

Jacob Skaria

Adding new worksheet BEFORE 1st worksheet
 
Try this..

Sheets.Add Befo=Sheets(1)
Sheets(1).name = "NewSheet"

--
If this post helps click Yes
---------------
Jacob Skaria


"Rob P" wrote:

I am calling several macros

the last of which is:

Sub summary()
Sheets.Add.Name = "1 day moves"
Sheets.Add.Name = "3 day moves"
End Sub

this inserts the 2 new worksheets BEFORE the very last sheet

how can I insert these BEFORE a specific worksheet called "template"

thank you
Rob


JamieH

Adding new worksheet BEFORE 1st worksheet
 
On Apr 21, 10:41*am, Rob P wrote:
I am calling several macros

the last of which is:

* * * * * Sub summary()
* * * * * * * Sheets.Add.Name = "1 day moves"
* * * * * * * Sheets.Add.Name = "3 day moves"
* * * * * End Sub

this inserts the 2 new worksheets BEFORE the very last sheet

how can I insert these BEFORE a specific worksheet called "template"

thank you
Rob


Try this...

Sub summary()
Sheets.Add.Name = "1 day moves"
Sheets.Add.Name = "3 day moves"
Sheets("1 day moves").Move Sheets("template")
Sheets("3 day moves").Move Sheets("template")
End Sub

Jacob Skaria

Adding new worksheet BEFORE 1st worksheet
 
Sorry I thought you are looking to insert as the first sheet. The below will
insert before 'Template'

Worksheets.Add(Befo=Worksheets(Sheets("template ").Index)).Name = "MySheet1"


--
If this post helps click Yes
---------------
Jacob Skaria


"Rob P" wrote:

I am calling several macros

the last of which is:

Sub summary()
Sheets.Add.Name = "1 day moves"
Sheets.Add.Name = "3 day moves"
End Sub

this inserts the 2 new worksheets BEFORE the very last sheet

how can I insert these BEFORE a specific worksheet called "template"

thank you
Rob



All times are GMT +1. The time now is 09:37 AM.

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