Message Box in a macro

G

Guest

I want to verify that certain cells aren't blank before continuing to run a
macro. ie: if the name field is left blank, the macro would stop and a
message box would pop up saying "A name must be entered" Once a message box
pops up and OK button is chosen, the macro would stop/reset and the user
would have to start the macro over again after filling in the name field.

A number of fields would be checked prior to continuing on with the macro.

Thank you very much.
 
E

Executor

Hi Modell

Try this:

Assuming you used named ranges:

Sub myMacro
If IsEmpty(Range("Name") then
Range("Name").Select
MsgBox "A name must be entered", vbOkOnly, "Form not completed"
Exit Sub
End If
If IsEmpty(Range("ZIP") then
Range("ZIP").Select
MsgBox "A zipcode must be entered", vbOkOnly, "Form not
completed"
Exit Sub
End If
End Sub

HTH,

Executor.
 

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