Assigning a number value to a combobox

glockster

Board Regular
Joined
Mar 24, 2002
Messages
181
In Excell 2002:
I'd like to assign a number value (3 points, 2 points, etc) depending on a text selection made in a combobox on a userform.
In otherwords: If you select "oranges" in the combobox, you are assigned a score of 2 points, those 2 points are added to the points of 3 other combobox selections and the result is displayed in a textbox on the same userform.
Thanks for any insight!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
If you have a table that describes those entries in a Range for example:
Book1
ABCD
1FruitPoints
2Apple1
3Oranges2
4Bananas3
Sheet1


then, in the code module for the Userform, put something like this:<font face=Courier New><SPAN style="color:#00007F">Option</SPAN><SPAN style="color:#00007F">Explicit</SPAN><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Sub</SPAN> ComboBox1_Change()
    <SPAN style="color:#00007F">If</SPAN> ComboBox1.ListIndex >= 0<SPAN style="color:#00007F">Then</SPAN>
        TextBox1.Value = ComboBox1.List(ComboBox1.ListIndex, 1)
    <SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">If</SPAN><SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Sub</SPAN> UserForm_Initialize()
    <SPAN style="color:#00007F">With</SPAN> ComboBox1
        .Clear
        .ColumnCount = 2
        .BoundColumn = 1
        .ColumnWidths = "; 0"
        .List = Sheets("Sheet1").Range("A2:B4").Value
    <SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">With</SPAN><SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,595
Members
449,089
Latest member
Motoracer88

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