Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving both values from a 2 column ComboBox VBA

Tags:

excel

vba

I have a user form (excel, VBA) where there is a 2 column combobox. When user selects a certain value from the combobox, I want to get the value he selected, and the value associated with the first value (ie. the second column value).

How do I do this? Simply ComboBox1.Value returns the value of the first column. ComboBox1.Value(0) doesn't work.

like image 286
emihir0 Avatar asked Apr 28 '15 15:04

emihir0


People also ask

How do I show the second column in ComboBox after selection?

Set the ColumnWidth to "0;100" and you will see the second column. Make sure that there is a working relationship between the width of the box and that of the columns to be displayed within it. Show activity on this post. Use a text field ond the right side of the combo box.

How do I add multiple columns in ComboBox VBA?

Multi-Column ComboBox from Worksheet Data (Easy Method) Go to the VBA window (Alt + F11) > Double-click the UserForm from the Project Explorer (Ctrl + R) > Click on the ComboBox and look to the Properties Window (F4). Change the ColumnCount property to the number of columns that you have.

How do I create a multiple column drop down list for a ComboBox in Excel?

Combo Box Settings To show two columns in the combo box, open its property window, and change its ColumnCount setting to 2. When you double-click on a data validation cell, event code runs, that finds the list used in the data validation cell. Then, “Full” is added to that name, to find the list for the combo box.

What is dynamic combo box?

This documentation is valid for: It is a type of control similar to a combo box, and the difference is that the set of possible values are read from a database table.


1 Answers

Use the column property of the combobox. It is 0-based so the first column is column(0) and the second column is column(1).

Me.ComboBox1.Column(1)
like image 156
Craig Weinzapfel Avatar answered Oct 04 '22 14:10

Craig Weinzapfel