Add items to Listbox based on criteria

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
I'm using this to load a Listbox on a Userform as the form is loaded;

Code:
ListBox4.RowSource = Range(Sheet5.Range("U2"), Sheet5.Range("U11").End(xlUp)).Address(, , , True)

I now need to take this a step further if possible - I now need to load only those values where the value of the 2nd offset column is "Yes".

Anyone?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
If your values in U are unique, try
Code:
Private Sub UserForm_Initialize()
   Dim Cl As Range
   Dim Dic As Object

   Set Dic = CreateObject("scripting.dictionary")

   For Each Cl In Sheet5.Range("U2", Sheet5.Range("U11").End(xlUp))
      If Cl.Offset(, 2).Value = "Yes" And Not Dic.exists(Cl.Value) Then Dic.Add Cl.Value, Nothing
   Next Cl
   Me.ListBox1.List = Dic.keys
End Sub
 
Upvote 0
Hi Fluff,

Thanks for the suggestion but it doesn't work I'm afraid - the Listbox doesn't refresh, not quite sure why.....
 
Upvote 0
Are the values in col W Yes, or could they be yes or YES
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

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