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

value and text in combo Excel vba

Posted on 2006-07-10
Last Modified: 2008-01-09

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.
Question by:nuberun
  • 3
  • 2
  • 2

Expert Comment

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


   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

Expert Comment

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

Author Comment

ID: 17073026

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Expert Comment

ID: 17073585
Ur application is in Visual Basic right..

Author Comment

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
LVL 15

Accepted Solution

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)
LVL 15

Expert Comment

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

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web 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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

829 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