VB not exiting sub

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
771
Office Version
  1. 365
Platform
  1. Windows
Good Morning,

I have a questionaire that has 25 questions that need to be answered before submit can be pressed to save the answers. I have managed to write the following to tell the person they have missed a question out, but it still allows the questionaire to be submitted.

Code:
   If Cells(17, 11) = "" Then
            Application.ScreenUpdating = False
            MsgBox "Please complete Question 1", vbOKOnly, "Missing Q1"
    Else
            MyQ1 = Cells(17, 11)
    End If

Is there anything i can add to stop the questionaire from being submitted.

Many Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi Gavin,

Maybe something like:

Code:
    If Cells(17, 11) = "" Then
        MsgBox "Please complete Question 1", vbOKOnly, "Missing Q1"
        TextBox1.SetFocus
        Goto endSub
    Else
        MyQ1 = Cells(17, 11)
    End If
.....
endSub:
        Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top