Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 74
Default 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,
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default 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,

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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,


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 74
Default 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,



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
Worksheet Tas position fgwiii[_2_] Excel Discussion (Misc queries) 2 April 2nd 08 09:39 PM
how do I fix the position of a worksheet in excel? MartyMac Excel Worksheet Functions 1 December 15th 06 06:07 PM
Set position into a worksheet using vba Ricardo Mercader Charts and Charting in Excel 2 October 22nd 05 07:09 PM
.position chazman Charts and Charting in Excel 4 February 28th 05 02:26 AM
Change position of move or copy worksheet option in Excel JesseAviles Excel Discussion (Misc queries) 1 February 22nd 05 10:25 PM


All times are GMT +1. The time now is 06:44 AM.

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"