+ Reply to Thread
Results 1 to 6 of 6

List Box List Index and Values

  1. #1
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Oxford
    MS-Off Ver
    Excel 2003, 2007 and 2010
    Posts
    120

    Thumbs up List Box List Index and Values

    Hey all,

    I want to be able to get a Item value from a List based on the List Index.

    Eg;

    Value List Index
    Orange 0
    Pear 1
    Apple 2

    so if the index is 0 it returns the value Orange. I then want to be able to assign it to a variable.

    I have tried code like this but it doesnt work.

    Please Login or Register  to view this content.
    any ideas would be great.

    thanks

    tom
    Last edited by t0m46; 08-11-2010 at 04:25 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: List Box List Index and Values

    What kind of ListBox and please wrap all code with code tags
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Oxford
    MS-Off Ver
    Excel 2003, 2007 and 2010
    Posts
    120

    Re: List Box List Index and Values

    Hey Sorry, forgot.

    Its a Listbox thats on a user form. a command button is pressed and i want to be able to get the all the items in the list box out .

    Thanks

  4. #4
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: List Box List Index and Values

    ListIndex returns the index of the currently selected value in the list. If you know which value you want to retrieve then you can use a literal...

    Please Login or Register  to view this content.
    If you want the currently selected value then the code would be:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: List Box List Index and Values

    If it is a single columnm without MultiSelect

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Oxford
    MS-Off Ver
    Excel 2003, 2007 and 2010
    Posts
    120

    Re: List Box List Index and Values

    Hey Thanks,

    works a lot more efficent than i had it.

    Was using a load of With......If.....Do.

    Thanks again.

    Tom

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1