Check before closing Excel

  • Thread starter Thread starter Keefy Boy
  • Start date Start date
K

Keefy Boy

I am using the Auto_Close procedure to perform several
actions before the workbook is closed. I no want to add
one hich checks if a specific field has been filled in. If
it has not, I want the Workbook not to close.

Any ideas?
 
Hi
try the following procedure in your workbook module (not in a standard
module):
Private Sub Workbook_BeforeClose(Cancel As Boolean)
with me.worksheets("sheet1").range("A1")
if .value="" then
msgbox "cell A1 on sheet1 not filled, cancel closing"
cancel=true
exit sub
end if
end with

'now your code

End Sub
 
Great, thanks. I was working in a standard module.

All works well now, cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top