Sub Delete_Last_Sheet()
Application.DisplayAlerts = False
Sheets(Sheets.Count).Delete
Call SaveFile_WithNewName
End Sub
Sub SaveFile_WithNewName()
Dim newName As String
newName = "NewWorkbook"
ActiveWorkbook.SaveAs Filename:=newName
End Sub
Last sheet may not be removed from original fileI’m sorry if I misunderstand
You say: I need a macro to move all sheets except last sheet to new workbook and save the new workbook
Which in my understanding means: save to the new workbook all sheets, except the last sheet (what my macro does), am I wrong?
Move sheets not copyLast sheet may not be removed from original file
Sub MoveSheetFromMasterToClosedWbk()
' Master book is source
' Book1 is destination
Dim mybook As Workbook
Application.ScreenUpdating = False
Set mybook = Workbooks.Open("C:\Temp\Book1.xlsx")
Workbooks("Master.xlsx").Sheets("Sheet1").Move After:=mybook.Worksheets(Sheets.Count) 'Specified Master book and sheet for moving or copying
Workbooks("Master.xlsx").Sheets("Sheet2").Move After:=mybook.Worksheets(Sheets.Count)
Workbooks("Master.xlsx").Sheets("Sheet3").Move After:=mybook.Worksheets(Sheets.Count)
mybook.Close SaveChanges:=True
Application.ScreenUpdating = True
End Sub
Sub MoveWs()
Dim wb1, wb2 As Workbook
Dim i, y As Long
Set wb1 = ThisWorkbook
Set wb2 = Workbooks.Add
y = 1
For i = 1 To wb1.Sheets.Count
If y = 0 Then Exit Sub
wb1.Sheets(y).Move After:=wb2.Sheets(wb2.Sheets.Count)
y = wb1.Sheets.Count - 1
Next
End Sub