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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
The general syntax is

Workbooks("Myfirst.xls").sheets("Sheet1").Move After:=Workbooks("Test.xls").Sheets("ATest")
 

GeorgeB

Board Regular
Joined
Feb 16, 2002
Messages
239
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
 

Leo Dhivyanandam A

New Member
Joined
Dec 20, 2017
Messages
1
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
 

Forum statistics

Threads
1,144,116
Messages
5,722,568
Members
422,447
Latest member
srclife

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
Top