Hello guys, can anyone help me edit this code, currently it closes all workbooks except the active one, I want it to close all except active workbook and another specific workbook.
I tried editing the code to close active workbook and another specific workbook using array, but it doesnt work.
Please help out.
Below is current code
Function CloseAll()
Dim wkbk As Workbook
Application.ScreenUpdating = False
'On Error GoTo errhandler
For Each wkbk In Application.Workbooks
If wkbk.Name <> Array(ActiveWorkbook.Name, "OTHERWORKBOOK.xlsm") Then
wkbk.Close savechanges:=False 'or make it true
End If
Next
'errhandler:
'For Each wkbk In Application.Workbooks
'If wkbk.Name <> ActiveWorkbook.Name Then
'wkbk.Close savechanges:=False 'or make it true
'End If
'Next
'Exit Function
'Application.ScreenUpdating = True
End Function
Thanks all.
Bookmarks