Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

value and text in combo Excel vba

Posted on 2006-07-10
10
Medium Priority
?
2,172 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 1000 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

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.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

916 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