Msg Box Userform

Abhishek1988

New Member
Joined
Oct 22, 2018
Messages
27
Hi Everyone,

Hope all are fine.

I have very basic knowledge about the VBA and looking out for some help.

I have a combo box in excel userform (cmboxabc), which is depend on multiple options buttons and one textbox value.

I want if all options buttons are unchecked and textbox value is blank and user try to see click on combo box to see dropdown value then user would be one error msg that "please select option button and provide text value".

Please help me with the same and also provide me the location where i need to paste required coding.

let me know if you have any further questions.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Re: Msg Box Userform Help

Try this out

Edit names accordingly

Code:
Private Sub ComboBox1_Change()
If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False Or TextBox1.Value = "" Then
        ComboBox1.Value = ""
        MsgBox "Please select option button and provide text value.", vbCritical
End If
End Sub
 
Last edited:
Upvote 0
Re: Msg Box Userform Help

What you could do is start the userform with the combobox Enabled=False. The user can't click on the box until the Enabled property is True.

Use the checkbox and textbox Change events to decide when conditions are right to change the Enabled to True

Code:
cmboxabc.Enabled = (TextBox1.Text <> vbNullString) And (OptionButton1.Value Or OptionButton2.Value Or OptionButton3.Value)
 
Upvote 0
Re: Msg Box Userform Help

thanks for response, i working fine but after clicking twice on cross button i am able to see the drop down and proceed. I want completely blank drop down.

Try this out

Edit names accordingly

Code:
Private Sub ComboBox1_Change()
If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False Or TextBox1.Value = "" Then
        ComboBox1.Value = ""
        MsgBox "Please select option button and provide text value.", vbCritical
End If
End Sub
 
Upvote 0
Re: Msg Box Userform Help

hanks for response. Can u pls help me where i should paste this coding? and i changed combo box property to false. what i shld do for text box and checkboxes?


What you could do is start the userform with the combobox Enabled=False. The user can't click on the box until the Enabled property is True.

Use the checkbox and textbox Change events to decide when conditions are right to change the Enabled to True

Code:
cmboxabc.Enabled = (TextBox1.Text <> vbNullString) And (OptionButton1.Value Or OptionButton2.Value Or OptionButton3.Value)
 
Upvote 0
Re: Msg Box Userform Help

thanks for response, i working fine but after clicking twice on cross button i am able to see the drop down and proceed. I want completely blank drop down.

Ahh ok...
@mikerickson suggestion will work better for that, enabling and disabling works much better rather than firing events.
 
Upvote 0
Re: Msg Box Userform Help

Thanks, can u pls explain me where is should paste his coding? i asked my query to him as welll. it would be great if you could help me. it's urgent
 
Upvote 0
Re: Msg Box Userform Help

Thanks it done. pls help me in other post for which i provided link

What you could do is start the userform with the combobox Enabled=False. The user can't click on the box until the Enabled property is True.

Use the checkbox and textbox Change events to decide when conditions are right to change the Enabled to True

Code:
cmboxabc.Enabled = (TextBox1.Text <> vbNullString) And (OptionButton1.Value Or OptionButton2.Value Or OptionButton3.Value)
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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