Data Validation

M

mantros

Hey folks,

Need help again...
C, i have a workbook wich destination is to work as a research one between
my clients.

I've made the whole thing and 've inserted a button with a macro that save
the file, right in the end of the sheet that wors as kind of a form.

My problem is that i want that macro, before it saves the file, do a kind of
validation of the data inserted in six different cells, denying the save
command and poping a validation error if the data is invalid.

Could u help, plz?
 
B

Bob Umlas, Excel MVP

The macro could do something like this:
Sub MaybeSave()
If Range("F3").value<>17 or _
Range("G12").value <> "Bob" or _
Range("G15").value <> "Ken" or _
Range("F1").value <> 33 or _
Range("A8").value <> 44 or _
Range("B33").value <> "Joe" then
Msgbox "Please Fill in the appropriate fields before this can
succeed.",vbexclamation
Exit Sub
End If
'Continue with whatever you had here.....
End Sub
 
M

mantros

i'll try it now...

Bob Umlas said:
The macro could do something like this:
Sub MaybeSave()
If Range("F3").value<>17 or _
Range("G12").value <> "Bob" or _
Range("G15").value <> "Ken" or _
Range("F1").value <> 33 or _
Range("A8").value <> 44 or _
Range("B33").value <> "Joe" then
Msgbox "Please Fill in the appropriate fields before this can
succeed.",vbexclamation
Exit Sub
End If
'Continue with whatever you had here.....
End Sub
 
M

mantros

Hey man, that worked! Thx for the advice... still a newbie with VBA...

Cya

"Bob Umlas, Excel MVP" escreveu:
 
Top