Results 1 to 4 of 4

Pre-selecting Listbox value from cell value in Userform

Threaded View

  1. #1
    Registered User
    Join Date
    07-17-2019
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    27

    Pre-selecting Listbox value from cell value in Userform

    Good Morning All!

    I am loading a userform that gets populated with a number of fields from a table depending on the currently selected row.

    I would like to use a listbox in the userform to give the user options to change a cell in that row. Effectively using a flat database and a basic front end to edit the data.

    I am struggling to get the listbox to be pre-selected with a value.

    I am populating the listbox with a dynamic named range to enable more options to be added in the future.

    Dim rRange As Range
    Dim rCell As Range
    Dim lCount As Long
    
    Set rRange = Range("STATUStbl")
    
        For Each rCell In rRange
            ListBox1.AddItem rCell.Value
        Next
    the above code successfully populates the listbox, the below code doesn't successfully autoselect the value in column 2 of the table!

         
    With ListBox1
            For lCount = 0 To .ListCount - 1
                If (.Column(2, lCount)) = Cells(ActiveWindow.RangeSelection.Row, 2) Then
                        .Selected(lCount) = True
                Else
                        .Selected(lCount) = False
                End If
            Next
    End With
    Please see attached, and please help!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] De-selecting on Listbox Query (When There Are Two Listboxes On Userform)
    By Necroscope in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-10-2019, 08:50 AM
  2. [SOLVED] Listbox selecting another first item after modification on sheet trough userform
    By dark_prince69 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-24-2018, 06:09 PM
  3. Userform Selecting listbox items erroneously
    By pjwhitfield in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 05-25-2015, 04:11 PM
  4. userform listbox
    By tsiguy96 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-14-2013, 11:09 PM
  5. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  6. Listbox - automatically selecting an option based on a cell's value
    By Smurlos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2011, 01:21 PM

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