![]() |
Check before closing Excel
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? |
Check before closing Excel
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 -- Regards Frank Kabel Frankfurt, Germany Keefy Boy wrote: 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? |
Check before closing Excel
Great, thanks. I was working in a standard module.
All works well now, cheers -----Original Message----- 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 -- Regards Frank Kabel Frankfurt, Germany Keefy Boy wrote: 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? . |
All times are GMT +1. The time now is 04:54 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com