VBA to move sheet to end

GeorgeB

Board Regular
Joined
Feb 16, 2002
Messages
239
Anyone have the syntax handy. I don't have help on my work computer. Tried following.


Sub NewPO()
Dim NewSheet As Worksheet
'Dim OldSheet As Worksheet
'Set OldSheet = Worksheets.Count
Sheets("1000").Copy After:=Sheets(1)

'Sheets("1000").Copy After:=Workbook.Worksheets.Count
Set NewSheet = ActiveSheet
'NewSheet.Move (After)OldSheet
NewSheet.Range("K1") = NewSheet.Range("K1").Value + 1
NewSheet.Name = Range("K1").Value
Sheets("1000").Range("K1") = NewSheet.Range("K1").Value
'ActiveSheet.Shapes("Button 1").Select
'Selection.Cut
ActiveSheet.Shapes("Button 1").Cut
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
The general syntax is

Workbooks("Myfirst.xls").sheets("Sheet1").Move After:=Workbooks("Test.xls").Sheets("ATest")
 
Upvote 0
Thanks Vog
However what I want is the code to move it to the end whatever that may be. This workbook is continually adding sheets and they need to be added at the end.
Thanks again
 
Upvote 0
If the sheet is not active and you want to have a specific sheet always at end of your workbook . try the below one.


ThisWorkbook.Worksheets.Item("Specificsheetname").Move After:=Worksheets(Worksheets.count).


Best Regards,

Leo
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,314
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top