Prevent Saving command if data is not validad

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Im trying to force the users to enter the correct format of the data needed,
ive found a way to prevent the save command, but i have not been able to
validate first. Id apreciate some help on this subject.
 
It will take a little more information that you have provided to make any
useful suggestions.
 
There is a event named BeforeSave in the Thisworkbook module that you can use

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Trim(Sheets("sheet1").Range("A1").Value) = "" Then Cancel = True
End Sub

This example check if there is somethin in cell A1 of "Sheet1"
 

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