Solved

How to get VBA Listbox text

Posted on 2014-04-11
3
232 Views
Last Modified: 2014-04-11
Hi - I have a listbox with a bunch of items added.  I know how to retrieve which is selected but I can't for the life of me remember how to retrieve the text of the selected item.  Arg...

Thanks!
Zack
0
Comment
Question by:zack4x4
[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
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
gplana earned 500 total points
ID: 39994572
There is a text property to get the text of a control, so just try this:
mytext =  your_control_name.text

where your_control is your control name.

Hope it helps. Regards.
0
 
LVL 15

Expert Comment

by:gplana
ID: 39994580
Also, if you want to know the text of an element from who you know its item number, you can do this:
     ListBox1.List(i)

where ListBox1 is the name of your ListBox, and i is the index (the selected index on your case).

Regards.
0
 
LVL 4

Author Closing Comment

by:zack4x4
ID: 39994746
Awesome thanks!  I tried for like 15 mins trying different things to remember how to do it lol.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

733 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