- excel vba close workbook without saving
- close active workbook vba
- save and close workbook vba
- excel vba save and close workbook without prompt
- close specific workbook vba
Workbooks("Book1.xlsx").Close
'''' Close Book1.xlsx only
YourWorkbook = "C\Desktop\Book1.xlsx"
Workbooks(YourWorkbook).Close
'''' Close YourWorkbook which is named in the your module
ActiveWorkbook.Close SaveChanges:=False
'''' Close current workbook on display only. Set SaveChanges:=True if you need to save
Sub SaveAndCloseOpenWorkbooks()
Dim wb As Workbook
With Application
.ScreenUpdating = False
For Each wb In Workbooks
With wb
If Not wb.ReadOnly Then
.Save
End If
If .Name <> ThisWorkbook.Name Then
.Close
End If
End With
Next wb
.ScreenUpdating = True
.Quit
End With
End Sub
'''' Close all open workbooks
Note:
- Just repeat Workbooks("Book1.xlsx").Close and change Book1 with Book2, Book3, etc if you need to close multiple known workbooks at the same time
- If you want to close the workbook that you are working on, use ActiveWorkbook.Close
- You can also use ActiveWorkbook.Save to save the active workbook
No comments:
Post a Comment