ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet Position (https://www.excelbanter.com/excel-programming/285894-re-worksheet-position.html)

todd

Worksheet Position
 
Where do I add this in the code to make it work?
-----Original Message-----
There's a parm you can add to the worksheets.add. (Look

at VBA's help for more
info)

but this is one way:

With ActiveWorkbook.Worksheets
Set shar = .Add(after:=.Item(.Count))
End With


Todd Huttenstine wrote:

The below code creates a new sheet, however when the new
sheet is created, it is placed in the first sheet
position. I would like the newly created sheet to be
placed at the end of all the other sheets. How do I do
this?

Thanx

Private Sub CommandButton1_Click()
Dim sha As Worksheet
Dim shar As Worksheet

Set sha = Worksheets(1)
Set shar = ActiveWorkbook.Worksheets.Add

sha.Cells.Copy

shar.Cells.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False

shar.Cells.PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False

shar.Name = sha.Range("E2").Value

ActiveWindow.DisplayZeros = False
Worksheets(2).Select
End Sub


--

Dave Peterson

.



All times are GMT +1. The time now is 05:01 PM.

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