ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I stop the close method in an auto close macro (https://www.excelbanter.com/excel-programming/377594-can-i-stop-close-method-auto-close-macro.html)

Paul

Can I stop the close method in an auto close macro
 
I have an auto close macro running on a file that demands certain cells are
complete before closing.

Is there a way of stopping the close method within the auto close macro when
the data is not present.

Bob Phillips

Can I stop the close method in an auto close macro
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'do your test and if true
Cancel = True

End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Paul" wrote in message
...
I have an auto close macro running on a file that demands certain cells

are
complete before closing.

Is there a way of stopping the close method within the auto close macro

when
the data is not present.




Paul

Can I stop the close method in an auto close macro
 
Bob - many thanks for your help - this is absolutely what I needed.

"Bob Phillips" wrote:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'do your test and if true
Cancel = True

End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Paul" wrote in message
...
I have an auto close macro running on a file that demands certain cells

are
complete before closing.

Is there a way of stopping the close method within the auto close macro

when
the data is not present.






All times are GMT +1. The time now is 03:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com