value and text in combo Excel vba


I want to know if it's possible to assign value and text information to a combo in vba to show the text and make the queries with the value.

Thanks in advance.
Who is Participating?
dave4dlConnect With a Mentor Commented:
Maintain an array of "behind-the-scenes" values that parallels the indices of the combo box.  Then when you need to access the value (not the displayed text) pull from the array using the index of the selected item in the combo box.

Or you could maintain your list of values in excel and access with vlookup (see
If your value field is a number field. you can set the text by using the additem method and
you can set the value data using the itemdata of a combobox


   Combo1.AddItem "Assyst"
   Combo1.ItemData(Combo1.NewIndex) = 1

if your value field is not a number field. you can make use of a string array and get the
required value data in the click event using the listindex as the array index.

Good Luck
Addition to above comment

You can get the value item by

1st method using the itemdata
     dim x
           x = combo1.itemdata(combo1.listindex)
2nd method
    suppose arrlist is the string array
    dim x
          x = arrlist(combo1.listindex)
Hope this will serve the purpose
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

nuberunAuthor Commented:

Thanks for your assistance but I don't have the itemdata property in the combo box.

Ur application is in Visual Basic right..
nuberunAuthor Commented:
This part is in Excel, using vba. In there is the option to assign the value and text to be displayed. I want to be able to do the same in Excel vba.
Thanks for your help
I believe my post answers the question (conceptual answer as well as a link)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.