View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Steve[_82_] Steve[_82_] is offline
external usenet poster
 
Posts: 7
Default Validation data on exit Excel or save

Something along these lines


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim DataNotValid As Boolean

If IsEmpty(Range("A1")) Then DataNotValid = True

If DataNotValid Then
Cancel = True
End If
End Sub

"Atram Informatika" wrote in message
...
Thank's on your answer, for example how would code look like if the cell
A1
can not be empty, how can i validate this befor exit or save. Thank's
sorry
on my english.
"Steve" wrote in message
...

The following workbook events should work


Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Validation check code here
'----
'----
'if data not valid then
'Cancel = True
'End If
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
'Validation check code here
'----
'----
'if data not valid then
'Cancel = True
'End If
End Sub

"Atram Informatika" wrote in message
...
How can I validate data when i exit excel aplication or when i save
workbook?
If data not valid then i must display message and do not exit

aplication,
or
save document.

Thank's