Thread: validate cells
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default validate cells

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Application.CountBlank(worksheets("Sheet1") _
.Range("A1:Z26")) 0 then
msgbox "Blank Cells Exist"
Cancel:=True
end if
End Sub

Make the workbook a window, then right click on the blue border at the top
and select view code.

this is the ThisWorkbook module. Put in code like the above.

However, What if the user is trying to close without saving?

Anyway, change the sheet name and the specified range to be what you want to
check.

http://www.cpearson.com/excel/events.htm
has general information on events - Chip Pearson's site.

--
Regards,
Tom Ogilvy


"Tammy H" <Tammy wrote in message
...
In Excel, how can I validate that a cell has data? If there are blank
cells,
I would like a message box when the user clicks on file to save or send.
Any
help would be greatly appreciated.