Have cell require input before saving.

  • Thread starter Thread starter couriced
  • Start date Start date
C

couriced

Is there a way to easily have a cell (or cells) require input, or th
file cannot be saved? I have a simple formula setup at the moment tha
simply warns if no entry is detected, however, that doesn't stop en
users from simply submitting the form anyway...
 
You would need a macro that is triggered by the save command. Such a macro
would check what you want checked, and if the conditions are not met the
save command would be cancelled. The macro can also display a message box
telling the user the error of his ways and what he must do before he can
save the file.
The macro would look like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Sheets("This").Range("A1")="" Or Sheets("That").Range("C5")="" Then
Cancel = True
MsgBox "Such and such."
End If
Post back if this fits with what you want and you need more. This macro
must be placed in the workbook module. To do that, right-click on the Excel
icon immediately left of the word "File" in the menu across the top of your
sheet, select View Code, and paste this macro in that module. Change the
sheet name(s) and cell addresses as needed. HTH Otto
End Sub
 

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

Back
Top