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
1,964 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
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.

911 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

16 Experts available now in Live!

Get 1:1 Help Now