Private Sub Workbook_BeforeClose(Cancel As Boolean)
If [xlRequiredCell] = "" Then
MsgBox "Please enter a value in [location].", _
vbOKOnly + vbExclamation, "Input required"
[xlRequiredCell].Select
Cancel = True
End If
End Sub
This procedure must be placed in the ThisWorkbook module. It fires when your user attempts to close the workbook. Setting Cancel=True cancels the close event.
This assumes that you have named a cell "xlRequiredCell". You could also just refer to it by an address like this: Range("B3"). I prefer naming cells, however, as this makes programming much simpler.
[purple]— Artificial intelligence is no match for natural stupidity.[/purple]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.