I’m unable to find out this information: Is it possible to show labels in these two type of lists rather than the real values ? of course when a label is selected, the value of the cell or the combobox (as a Form control) gets the real value.
Product A <——> 10
Product B <——> 11
Product C <——> 22
Combobox shows: Product A, Product B and Product C
If I select A I get the 10 value, B the 11 value and C the 22 value
Thank you in advance
The typical way of doing this is to have a lookup table. There’s a function named something like VLOOKUP (that’s a partial name) that you can use in formulas to retrieve the value. I did something like this at my job, and I created a lookup table in a separate spreadsheet, and then called the lookup function in my main one.
You can also use macros, but that is too much bother in my opinion for the current problem.
Data Validation: You can’t have two values per row. You can use a lookup table to convert one value to another. Or you can combine the values like “ProductA_10” and use a formula to extract the “10” where you need it.
Form Combobox: This also has limited options and doesn’t really offer anything more than DV does for what you want.
Toolbox Combobox: This can do just about anything you want. You would set the ColumnCount property to 2, the BoundColumn property to 2, and the ColumnWidths property to something like “1;0” to hide the second column. If I had ProductA-C in A1:A3 and 10-12 in B1:B3, then I would use code like this in a standard module to fill the combobox
Sub LoadCombobox() Dim rCell As Range For Each rCell In Sheet1.Range("A1:A3").Cells Sheet1.ComboBox1.AddItem rCell.Value Sheet1.ComboBox1.List(Sheet1.ComboBox1.ListCount - 1, 1) = rCell.Offset(0, 1).Value Next rCell End Sub
And code like this in the sheet’s module to put a value in a cell (F1 in this example)
Private Sub ComboBox1_Change() Me.Range("F1").Value = Me.ComboBox1.Value End Sub
Whenever a new value in the combobox is selected, F1 is updated. We can use the Value property of the combobox because we set the BoundColumn property to the column with the value we want.