Link to home
Start Free TrialLog in
Avatar of nuberun
nuberun

asked on

value and text in combo Excel vba

Hello,

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.
Avatar of assyst
assyst

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

eg.

   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
Avatar of nuberun

ASKER

Hi,

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

Regards
Ur application is in Visual Basic right..
Avatar of nuberun

ASKER

This part is in Excel, using vba. In vb.net 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
ASKER CERTIFIED SOLUTION
Avatar of dave4dl
dave4dl

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I believe my post answers the question (conceptual answer as well as a link)