Results 1 to 3 of 3

Thread: [RESOLVED] USER FORM : ListBox population based on another ListBox value selection [VBA]

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2019
    Posts
    37

    Resolved [RESOLVED] USER FORM : ListBox population based on another ListBox value selection [VBA]

    Hi,

    User Form :


    Worksheet :



    In my User form there is listbox which consists of 3 values. Rated Current_Order set 1 , Rated Current_Order set 2 , Rated Current_Order set 3.

    Based on the selection of these 3 order set , values should populate in the corresponding right side listbox , "Values for the selected attribute" .

    The Values are populated from the worksheet "AttrOrderSetDefinition" .(Please refer the screenshot) .

    If we select 1st orderset , values from "G3" to its end should populate in the next listbox. if we select 2nd , values from "H3" should populate and similar for the 3rd.

    Someone please help me for this code.

    westconn1 is my daily savior .

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: USER FORM : ListBox population based on another ListBox value selection [VBA]

    assuming that the order set are in order in the list box you can use the index of the first listbox to specify the column for the data

    Code:
    Private Sub ComboBox1_Click()
    popnxtlist ComboBox1.ListIndex
    End Sub
    Sub popnxtlist(i As Integer)
    dim r as range
    set r = Range("g3").Offset(, i).Address
    MsgBox r.address
    ' populate the next listbox from the data below r
    note i used a combobox but a listbox would be the same
    the popnxtlist can be used generically for any number of listboxes, by passing the target listbox with the listindex as a second parameter
    eg if you had 4 or 5 cascading, each filled from the value selected in the previous one this procedure would save writing the code multiple times for each list box
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2019
    Posts
    37

    Re: USER FORM : ListBox population based on another ListBox value selection [VBA]

    @wetconn1 Working fine as usual . Thanks a lot.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width