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,437 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
[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 Comments
 
LVL 51

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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 demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

737 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