Data Validation...

K

K

I understand the concept of the cell validation within Excel 2000, but how
can I prevent a workbook from being saved if the cell is empty? Right now I
have some cells that I have been set to allow a minimum text limit of 5
characters, but if I do not actually select the cell and hit <F2> for input,
the user will never receive an error stating that they forgot to fill in the
data.

So, is it possible to restrict a user from saving the workbook if a specific
cell is left empty?

Thanks
K
 
B

BS

Hi;
paste these into the codes of ThisWorkbook

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If a1 = "" Then
MsgBox ("The cell is empty")
Exit Sub
End If
End Sub

if you try to save the workbook and if a1 is empty then a messagebox appears
but after that you can save your workbook. A warning only :)

perhaps it can give an idea

Burçin SARIHAN
 
E

Earl Kiosterud

K,

You can use this event macro. But macros must be enabled for it to work. It
goes in the ThisWorkbook module.
:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Sheets("Sheet1").Range("A1") = "" Then
MsgBox "You have to enter some stuff into A1 before you save the file.
Save cancelled."
Cancel = True
End If
End Sub

Or you may be able to use Data Validation (which can refer to cells other
than the cell being validated, thus your cell of interest) to force entries
at data entry time.

Earl Kiosterud
Mvpearl omitthisword at verizon period net.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top