ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Add worksheet at end or last position (https://www.excelbanter.com/excel-discussion-misc-queries/199241-add-worksheet-end-last-position.html)

Brent E

Add worksheet at end or last position
 
Good day,

I would like to set up a small VBA sub that will simply dynamically add a
sheet at the end or last position of the worsheet regardless of the no. of
worksheets in the workbook and independent of the worksheet names.

For example, if worksheetA has 2 worksheets titled, "A", and "B", if I run
the code, a sheet would be added after "B."

If worksheetB has worksheets titled: "Sheet1", "Sheet2", "Sheet3", and
"Sheet4", the code would add a sheet after Sheet4.

What is the VBA code be to do this? Please advise.

Thanks Much.

Cordially,

FSt1

Add worksheet at end or last position
 
hi
this might work for you
Sub addsheet()
Dim c As Long
c = Worksheets.Count
Worksheets.Add after:=Sheets(c)
End Sub

regards
FSt1

"Brent E" wrote:

Good day,

I would like to set up a small VBA sub that will simply dynamically add a
sheet at the end or last position of the worsheet regardless of the no. of
worksheets in the workbook and independent of the worksheet names.

For example, if worksheetA has 2 worksheets titled, "A", and "B", if I run
the code, a sheet would be added after "B."

If worksheetB has worksheets titled: "Sheet1", "Sheet2", "Sheet3", and
"Sheet4", the code would add a sheet after Sheet4.

What is the VBA code be to do this? Please advise.

Thanks Much.

Cordially,


Jim May[_3_]

Add worksheet at end or last position
 
in article , Brent E at
wrote on 8/18/08 4:41 PM:


Sub Macro1()
Sheets.Add After:=Sheets(Sheets.Count)
End Sub


Good day,

I would like to set up a small VBA sub that will simply dynamically add a
sheet at the end or last position of the worsheet regardless of the no. of
worksheets in the workbook and independent of the worksheet names.

For example, if worksheetA has 2 worksheets titled, "A", and "B", if I run
the code, a sheet would be added after "B."

If worksheetB has worksheets titled: "Sheet1", "Sheet2", "Sheet3", and
"Sheet4", the code would add a sheet after Sheet4.

What is the VBA code be to do this? Please advise.

Thanks Much.

Cordially,



Rick Rothstein \(MVP - VB\)[_1130_]

Add worksheet at end or last position
 
This should do what you want....

Sub AddNewLastSheet()
Worksheets.Add After:=Worksheets(Worksheets.Count)
End Sub

Rick


"Brent E" wrote in message
...
Good day,

I would like to set up a small VBA sub that will simply dynamically add a
sheet at the end or last position of the worsheet regardless of the no. of
worksheets in the workbook and independent of the worksheet names.

For example, if worksheetA has 2 worksheets titled, "A", and "B", if I run
the code, a sheet would be added after "B."

If worksheetB has worksheets titled: "Sheet1", "Sheet2", "Sheet3", and
"Sheet4", the code would add a sheet after Sheet4.

What is the VBA code be to do this? Please advise.

Thanks Much.

Cordially,



Brent E

Add worksheet at end or last position
 
Great. Thanks All! Looks like all of those suggestions will work. (=

"Rick Rothstein (MVP - VB)" wrote:

This should do what you want....

Sub AddNewLastSheet()
Worksheets.Add After:=Worksheets(Worksheets.Count)
End Sub

Rick


"Brent E" wrote in message
...
Good day,

I would like to set up a small VBA sub that will simply dynamically add a
sheet at the end or last position of the worsheet regardless of the no. of
worksheets in the workbook and independent of the worksheet names.

For example, if worksheetA has 2 worksheets titled, "A", and "B", if I run
the code, a sheet would be added after "B."

If worksheetB has worksheets titled: "Sheet1", "Sheet2", "Sheet3", and
"Sheet4", the code would add a sheet after Sheet4.

What is the VBA code be to do this? Please advise.

Thanks Much.

Cordially,





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

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