Combo Box Value depend on checkbox and TextBox - USERFORM

Rahulwork

Active Member
Joined
Jun 9, 2013
Messages
284
Hello Everyone,

I have a userform in which i made two combo box, below are the name's

ComFruits_Change()

ComVeg_Change()

Both combo box having informations like below:

Private Sub UserForm_Initialize()

ComFruits.AddItem "Apple 1"
ComFruits.AddItem "Apple 2 "
ComFruits.AddItem "Orange 1"
ComFruits.AddItem "Orange 2"
ComVeg.AddItem "Tomato 1"
ComVeg.AddItem "Tomato 2"
ComVeg.AddItem "Potato 1"
ComVeg.AddItem "Potato 2""



Now i have two check boxes, below are the name's

Private Sub Fruit_Click()


End Sub

Private Sub Vegetable_Click()


End Sub


and last i have one text box, below is the name:

Private Sub txtABC_Change()


End Sub



Now i want if Fruit checkbox is checked then ComFruits_Change() , should be active and other one should be inactive, same with if Vegetable checkbox is checked then ComFruits_Change() should be inactive and other one should be active.

then if txtABC value is apple then under ComFruits_Change(), apple 1 and apple 2 value should reflect, same if value is orange then ComFruits_Change(), orange 1 and orange 2 should reflect.


Please help me with the same. i tried but couldn't happn
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I do not understand this part of your question.
You said:
then if txtABC value is apple then under ComFruits_Change(), apple 1 and apple 2 value should reflect, same if value is orange then ComFruits_Change(), orange 1 and orange 2 should reflect.

What does reflect the same mean


 
Upvote 0
Hey I m sorry for confusion,

ComFruits_Change() has two option in drop down, Apple 1, apple 2, orange 1 and orange 2.

there is text box, if text box value is apple, then ComFruits_Change() should show only apple 1 and apple 2. same if text box value is orange then ComFruits_Change() should show only orange 1 and orange 2 in dropdown.

i got to know that it could be possible if i group the options but i dont know how to do that. pls help.

let me know if you have any further question. thanks fr response,
 
Upvote 0
So you have already loaded all kinds of Fruit into the Fruit combobox

But if a user puts Apple into Textbox then you want all the other fruits removed from the Combobox and only show any fruit which name starts with Apple
Meaning now to reload the combobox with all other fruits you will have to reload them like you did when you opened the Userform.


And when you say make Combobox Active and inactive

You said this:
should be active

Do you want the Combobox selected or do you mean you want the Combobox Enabled
Enabled means it can be selected.
Not being enabled means it cannot be selected or used.
 
Upvote 0
USERFORM Combo box

Hello Everyone,

I have a userform in which i made two combo box, below are the name's

ComFruits_Change()

ComVeg_Change()

Both combo box having information like below:
Code:
Private Sub UserForm_Initialize()

ComFruits.AddItem "Apple 1"
ComFruits.AddItem "Apple 2 "
ComFruits.AddItem "Orange 1"
ComFruits.AddItem "Orange 2"
ComVeg.AddItem "Tomato 1"
ComVeg.AddItem "Tomato 2"
ComVeg.AddItem "Potato 1"
ComVeg.AddItem "Potato 2""


Now i have two check boxes, below are the name's
Code:
Private Sub Fruit_Click()


End Sub

Private Sub Vegetable_Click()


End Sub

and last i have one text box, below is the name:
Code:
Private Sub txtABC_Change()


End Sub


Now i want if Fruit checkbox is checked then ComFruits_Change() , should be data should reflect and Vegetable_Click() data shouldn't reflect same with if Vegetable checkbox is checked then ComFruits_Change() data shoudn't reflect and other Combo box one data should reflect.

then if txtABC value is apple then under ComFruits_Change(), apple 1 and apple 2 value should reflect, same if value is orange then ComFruits_Change(), orange 1 and orange 2 should reflect.


Please help me with the same. i tried but couldn't happn
 
Last edited by a moderator:
Upvote 0
Re: USERFORM Combo box

It sounds like you should be using Option Buttons instead of Check Boxes, since both being checked isn't an option.

With that changed, I think this will do what you want
Code:
Private Sub ComFruits_Click()
    Call Fruit_Change
End Sub

Private Sub ComVeg_Click()
    Call Fruit_Change
End Sub

Private Sub Fruit_Change()
    If Fruit.Value Then
        txtABC.Text = ComFruits.Text
    Else
        txtABC.Text = ComVeg.Text
    End If
End Sub

Private Sub UserForm_Initialize()
    With ComFruits
        .AddItem "Fruit 1"
        .AddItem "Fruit 2"
        .AddItem "Fruit 3"
    End With
    With ComVeg
        .AddItem "Veg 1"
        .AddItem "Veg 2"
        .AddItem "Veg 3"
    End With
    Fruit.Value = True
End Sub
 
Upvote 0
Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. (rule 12 here: Forum Rules).

I have merged both threads.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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