Solved

How can I return the ListIndex value of an item in a Listbox on an Excel VBA user form ?

Posted on 2013-11-03
2
2,054 Views
Last Modified: 2013-11-03
Hi Experts,

I have an Excel VBA User form with a Listbox control (called 'liSales').

I want to search through the Listbox items on the first field (Invoice number, actually) and return the ListIndex value when a matching entry is found.

What is the most efficient way of coding this ?

Thanks
Toco
0
Comment
Question by:Tocogroup
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39619748
Hi

pls try

Dim i   As Long
Found = False
With Me.liSales
    For i = 0 To .ListCount - 1 
        If .List(i, 1)  = "Your Value" Then 
            Idx = i
            Found = True
        End If 
    Next 
End With

Open in new window

Regards
0
 

Author Closing Comment

by:Tocogroup
ID: 39619776
Thanks for that. I didn't realise you could access the list in the listbox as if it was an array.
Regards
Toco
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now