Populate textbox dependent on combobox value

Mikeymike_W

Board Regular
Joined
Feb 25, 2016
Messages
171
Hi There,

I have no idea where to start with this so would love some help.

I have four comboboxes with twelve colours on the list (each has an identical list). Say the colour "Red" is selected in the combobox i want the textbox to populate with information which corresponds to the Value "Red"; this information is on sheet 2.
Now if they choose a second colour from combobox 2 i'd then like that to be added on to the information that was acquired from combox one and inserted within the textbox... the same would apply for combobox 3 & 4.

I hope this makes sense.

Thanks in advance for any help you can give,

Mike
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
We always need specific details.
Like you said:

i want the textbox to populate with information which corresponds to the Value "Red"; this information is on sheet 2.

You did not say where on sheet 2

And corresponds is a vague term.
 
Upvote 0
So the information is in a table on sheet 2 called "foundation". This table has the twelve colours in column A and next to them in column B is the corresponding data which i would want to appear in the textbox.
 
Upvote 0
So if the colors are in a Table why do you need the comboboxes?

You said:

This table has the twelve colours in column A

I have four comboboxes with twelve colours on the list (each has an identical list).

I need to know what will activate the script?

When you choose a value from a combobox or click on a cell in the Table


 
Upvote 0
I'm not too sure how else to say it.

In sheet one there are 4 combo boxes, each one has a list of twelve colours. When a colour is selected I would like information about that colour to appear in a text box (textbox1) on sheet one.
The information about each colour which I want to appear in textbox1 is located within a table named "foundation" in sheet2.

So what I need to happen is when I select a colour in combobox1 it will search for that colour in the table in sheet 2 then take the information about that colour from the table and place it in textbox1 in sheet1.

I also want the same thing to happen for the other combo boxes but without overwriting the information already in textbox1 from the previous combo box.

The trigger would be selecting the item in the combo box. Perhaps a worksheet change or just a change event in the combo box??
 
Upvote 0
I would like for you to give me a couple examples.


So if in Combobox you select Red

You said:
So what I need to happen is when I select a colour in combobox1 it will search for that colour in the table in sheet 2 then take the information about that colour from the table and place it in textbox1 in sheet1.

So we search Column 1 of the table for red and Take what information from the Table??

Do you mean Take information from column 2 of the table

Tables do not have columns A and B

A Table has column like column 1 column 2 column 3

That is because a Table may be in column A B and C or it may be columns F G and H

So table columns are referred to as Table Named:
Sheet2 Listobject("foundation").column 1
 
Last edited:
Upvote 0
Hi,

So in the table the information is in the second column, the colours are in the first column.
So if "Red" is in the first column then against it in the second column would be "A deep rich colour, passionate and violent"... this is the information i want to appear in the textbox
In column one all the colours are listed and against each (in column two) is information about that colour which i want to appear in the textbox dependent on the choices made in the combobox. Again I want this to happen so that if colours are chosen in all four comboboxes that the information in the textbox is not deleted but added onto the information from the other comboboxes.

Many thanks,

Mike
 
Upvote 0
You would need to put this code in all 4 ComboBoxes

The script searches Sheet(2).Table named "foundation" Column(1) and adds the value in column(2) of the Table into TextBox1 on sheet1

Code:
Private Sub ComboBox1_Change()
'Modified  9/20/2019  5:47:05 AM  EDT
Dim SearchString As String
Dim SearchRange As Range
SearchString = ComboBox1.Value  ' Modify for each ComboBox
Set SearchRange = Sheets(2).ListObjects("foundation").ListColumns(1).Range.Find(SearchString, LookIn:=xlValues, lookat:=xlWhole)
If SearchRange Is Nothing Then MsgBox SearchString & "  Not Found": Exit Sub
TextBox1.Value = TextBox1.Value & SearchRange.Offset(, 1).Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,212,927
Messages
6,110,730
Members
448,294
Latest member
jmjmjmjmjmjm

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