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,702 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 52

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

627 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