Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Worksheet Tas position | Excel Discussion (Misc queries) | |||
how do I fix the position of a worksheet in excel? | Excel Worksheet Functions | |||
Set position into a worksheet using vba | Charts and Charting in Excel | |||
.position | Charts and Charting in Excel | |||
Change position of move or copy worksheet option in Excel | Excel Discussion (Misc queries) |