Solved

value and text in combo Excel vba

Posted on 2006-07-10
10
2,151 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:nuberun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
10 Comments
 
LVL 7

Expert Comment

by:assyst
ID: 17072750
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
0
 
LVL 7

Expert Comment

by:assyst
ID: 17072772
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
0
 

Author Comment

by:nuberun
ID: 17073026
Hi,

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

Regards
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Expert Comment

by:assyst
ID: 17073585
Ur application is in Visual Basic right..
0
 

Author Comment

by:nuberun
ID: 17073662
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
0
 
LVL 15

Accepted Solution

by:
dave4dl earned 250 total points
ID: 17074445
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 http://www.exceltip.com/st/Add_Combo_Box_to_a_Sheet_in_Microsoft_Excel/300.html)
0
 
LVL 15

Expert Comment

by:dave4dl
ID: 17228832
I believe my post answers the question (conceptual answer as well as a link)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Starting up a Project

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question