Message Box for a Userform

DevinSutherland

New Member
Joined
Nov 2, 2015
Messages
11
I am having a problem with getting a message box to open and close when I need them to.

lets say text box 1, 2, 3, 4, 5, all have to have something entered in the fields when I click the Submit button. If they do not have something in the field then I want a message box to pop up saying the field needs to be completed. Then I want the Userform to stay open and when the Submit button is clicked again and all fields are completed then I want to unload the userform.


If TextBox1.Value = "" Then MsgBox ("Enter Date"), vbOkCancel
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
The code you posted looks fine, what exactly are you having problems with?
 
Upvote 0
If TextBox57.Value = "" Then MsgBox ("Enter Date")
If ans = vbok Then Forecast.Show Else
Unload Me

well it unloads after you click ok it wont show the userform, it closes it after Ok is clicked.
 
Upvote 0
Try this.
Code:
If TextBox57.Value = "" Then 
    MsgBox "Enter Date"
    Exit Sub
End If
 
Upvote 0
that works, now how to you string more than one of those together?

If TextBox57.Value = "" Then
MsgBox ("Enter Date")
If TextBox59 = "" Then
MsgBox ("Enter Initials")
Exit Sub
End If
Unload Me

because that doesn't work
 
Upvote 0
Try this.
Code:
If TextBox57.Value = "" Then
    MsgBox ("Enter Date")
    Exit Sub
End if
If TextBox59 = "" Then
    MsgBox ("Enter Initials")
    Exit Sub
End If
 
Upvote 0
If TextBox57.Value = "" Then
MsgBox ("Enter Date")
Exit Sub
End if
If TextBox59 = "" Then
MsgBox ("Enter Initials")
Exit Sub
End If
Unload Me

The first one work perfect but when you add the second string in there it closes the form and doesn't keep it open after you click ok.
 
Upvote 0
I think I got it!
If TextBox57.Value = "" Then
MsgBox ("Enter Date")
Exit Sub
End If
If TextBox59.Value = "" Then
MsgBox ("Enter Initials")
Exit Sub
End If
Unload Me

thanks for all of the help!!!
 
Upvote 0
The code will not clos the userform if either TextBox57 or TextBox 59 are empty.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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