Populate ActiveX Listbox from criteria

jbroge

New Member
Joined
Dec 12, 2018
Messages
2
Hi all. I'm trying to fill the list box (ActiveX) with names that have an active flag and skip names who don't have an active flag.

TomActive
KennyActive
CarrieNot Active
JaneActive
EdNot Active

<tbody>
</tbody>

I created an named range that refers to both columns and entered it into the "ListFillRange" in the properties window and set "ColumnCount" to 2. This shows both columns inside the list box, but I don't know what to do next to only show those who are "Active".

Thanks in advance!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
First, clear the ListFillRange property. Then try the following code...

Code:
    Dim lbx As MSForms.ListBox
    Dim i As Long
    
    Set lbx = Worksheets("Sheet1").ListBox1
    
    With Range("MyNamedRange")
        For i = 1 To .Rows.Count
            If UCase(.Cells(i, 2).Value) = "ACTIVE" Then
                lbx.AddItem .Cells(i, 1).Value
                lbx.List(lbx.ListCount - 1, 1) = .Cells(i, 2).Value
            End If
        Next i
    End With

Change the sheet name, and the name of your named range, accordingly.

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,831
Messages
6,127,142
Members
449,362
Latest member
Bracelane

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top