[Solved] Is there a macro I can put on a command button, to move the current sheet to a different closed workbook? [closed]


Insert a button on the workbook and assign this code to the button, make sure to change the filename path to yours:

Private Sub CommandButton1_Click()
    On Error Resume Next
    Dim sheetIndex As Integer
    sheetIndex = 1
    Application.ScreenUpdating = False
    Workbooks.Open Filename:="C:\YourPath\Completed Workorders.xlsm"
    Windows("Workorders.xlsm").Activate
    ActiveSheet.Select
    ActiveSheet.Copy Before:=Workbooks("Completed Workorders.xlsm").Sheets(sheetIndex)
    sheetIndex = sheetIndex + 1

    ActiveWorkbook.Save
    Windows("Completed Workorders.xlsm").Close
    Application.DisplayAlerts = False
    ActiveSheet.Delete
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub

16

solved Is there a macro I can put on a command button, to move the current sheet to a different closed workbook? [closed]