+ Reply to Thread
Results 1 to 8 of 8

Select Cells from Listbox on Userform

Hybrid View

Jonathan78 Select Cells from Listbox on... 03-24-2011, 03:11 AM
royUK Re: Select Cells from Listbox... 03-24-2011, 04:47 AM
Jonathan78 Re: Select Cells from Listbox... 03-24-2011, 05:53 AM
royUK Re: Select Cells from Listbox... 03-24-2011, 06:27 AM
Jonathan78 Re: Select Cells from Listbox... 03-24-2011, 06:44 AM
royUK Re: Select Cells from Listbox... 03-24-2011, 06:45 AM
Jonathan78 Re: Select Cells from Listbox... 03-24-2011, 06:54 AM
Jonathan78 Re: Select Cells from Listbox... 03-24-2011, 08:35 AM
  1. #1
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Select Cells from Listbox on Userform

    Hi all,

    I use a listbox on a userform to show the data from range B2:B300
    Is there a way to select the corresponding cell of the item selected in the listbox?
    Last edited by Jonathan78; 03-24-2011 at 08:36 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: Select Cells from Listbox on Userform

    Use the ListBox's ListIndex. This starts from Zero so if the data starts in A1 the ListIndex+1, etc
    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
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Select Cells from Listbox on Userform

    I'm not familiar with the ListIndex.
    Would you mind taking a look at the attached sheet?
    Attached Files Attached Files

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

    Re: Select Cells from Listbox on Userform

    The code looks familiar.

    The ListBox already has code to populate the textboxes based on clicking it

  5. #5
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Select Cells from Listbox on Userform

    But it doesn't work

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

    Re: Select Cells from Listbox on Userform

    What doesn't work, it looks like it's working to me.

    What exactly are you trying to do?

  7. #7
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Select Cells from Listbox on Userform

    When the delete button is hit on the userform, it delete's the wrong item.
    I'd like it to delete the selected item on the listbox

  8. #8
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Select Cells from Listbox on Userform

    Hello royUK,

    I found the anwer on another thread, funny enough, given by you

        Dim I As Long
        With Me.ListBox1
            For I = .ListCount - 1 To 0 Step -1
                If .Selected(I) Then Sheets("DATA").Rows(I + 1).EntireRow.Delete
            Next I
        End With

+ 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