Hey, thank you very much for your response!
I have a few more informations on the problem now.
I am at my home computer (Excel 2016) and this is the code I am using:
Option Explicit
Private Sub Workbook_Open()
varPrintDone = False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim lastRowShipping As Long
With Sheets("Shipping")
lastRowShipping = IIf(IsEmpty(.Cells(.Rows.Count, 2)), .Cells(.Rows.Count, 2).End(xlUp).Row, .Rows.Count)
End With
If varPrintDone = False Then
If lastRowShipping = 6 Then
Application.DisplayAlerts = False
Application.Quit
Application.DisplayAlerts = True
ElseIf lastRowShipping <> 6 Then
noPrintDoneForm.Show
Cancel = True
End If
End If
End Sub
And everything works, but Workbook_BeforeClose only fires once a session.
Now, today I tested this exact same code (same file) on another computer (Excel 2010) and it does work just the way I want it to work, every single time I press the eXit-Button, when varPrintDone = false and lastRowShipping <> 6, my UserForm (noPrintDoneForm) pops up.
What could be the root of the problem at my home computer?
The only two (to me known) differences are the Excel Version (2016 - 2010) and that on my computer, when I open more than one Excel file I do have them seperately shown on my desktop/screen (can move both of them on my desktop, for example put them next to each other and watch both of them at the same time), while on the other computer, when you open more than one file, there is only one file showing up. When you switch between the files the other ones aren't shown.
Uh, sorry for my English, I hope it is understandable.
So the code does work, but not at my home computer.
Kind regards.