I got it! :D
RaulRodriguez, thanks for helping me on my way.
The solution:
Since code 2 is closing my Excel anyhow I can turn off all private subs.
The problem was that my private was running all the time even nanoseconds (whatever) before executing the line: ThisWorkbook.Close savechanges:=True
The way it looks now:
Code 1Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Close workbook without saving changes.
ThisWorkbook.Saved = True
End Sub
Code 2Sub Clean_Save_Close()
Application.EnableEvents = False ' <----- Key to the solution
ThisWorkbook.Saved = False
Application.Run "'All-in-one.xlsm'!ThisWorkbook.Clear_ZS_Calc"
Application.Run "'All-in-one.xlsm'!ThisWorkbook.Clear_USD_Calc"
Application.Run "'All-in-one.xlsm'!ThisWorkbook.Sort_Customer_Confirmationlist"
Sheets("4.2").Select
Range("E10").Select
Selection.ClearContents
Range("L10").Select
ActiveCell.FormulaR1C1 = "ne"
Sheets("0").Select
ThisWorkbook.Close savechanges:=True
End Sub
Bookmarks