Consulting

Results 1 to 3 of 3

Thread: Quick question about Listboxes

  1. #1
    VBAX Regular
    Joined
    Jun 2016
    Posts
    8
    Location

    Quick question about Listboxes

    Hello,
    I'm sure I'm missing something obvious, but I've searched around and can't find the answer.

    I'm working with a Userform, and on it is a listbox. The user submits an amount of entries, say 10. Once that's done, I want to extract a particular entry via VBA and assign it to a variable.

    For example, say I want to assign entry number 6 to the variable n...

    Pseudocode being:

    n = lstListBox1.getvalue(6)

    What code should I be using?

    Thanks,
    Charlie.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    n = lstListBox1.List(5)
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Jun 2016
    Posts
    8
    Location
    Quote Originally Posted by mdmackillop View Post
    n = lstListBox1.List(5)
    you're a star cheers pal

Posting Permissions

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