Thread
:
Hold closing the sheet...
View Single Post
#
2
Posted to microsoft.public.excel.programming
Nick Hodge
external usenet poster
Posts: 1,173
Hold closing the sheet...
Sridhar
Set the Cancel Boolean to True and the workbook will not close
Private Sub Workbook_BeforeClose(Cancel As Boolean)
{ Validate the data }
If Error Msgbox ( " Error .... Correct the Data " )
Cancel = True
End Sub
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS
"Sridhar Pentlavalli via OfficeKB.com" wrote in message
...
Hi
I have to validate the data at the time of closing the sheet. If some
errors are present in the data, I need to throw a message and I should not
close the sheet.
I am using the following code to achieve it. Here the problem is I can
throw an error message if the data is wrong but how to stop the work book
from closing. I have to give a chanse to user to correct the data. How
this can be achieved?
Private Sub Workbook_BeforeClose(Cancel As Boolean)
{ Validate the data }
If Error Msgbox ( " Error .... Correct the Data " )
End Sub
--
Message posted via
http://www.officekb.com
Reply With Quote
Nick Hodge
View Public Profile
Find all posts by Nick Hodge