Help with pre-populating listbox based on certain criteria!!!

cory0789

New Member
Joined
Sep 3, 2014
Messages
17
I am trying to create a listbox in an order sheet that populates the listbox with Names from a master sheet by comparing the Store number.

So Store number in Sheet1 = 999
The bottom of the order sheet has Food Products or should, I want a listbox there that populates the food product names from the master list by adding whatever items from Sheet 2 that have Store number = 999 in Colum C...

So, Store number in Sheet1 = 999
Sheet 2
Column A Column C
Lettuce 999
Tomatoes 999
Bread 742
Onions 874

So the listbox should have Lettuce and Tomatoes in it not the others... obviously this is a small example and there are hundreds of items but can someone please help me on how to do this... I cannot figure it out using VBA...
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Try something like:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG04Sep16
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("C2"), Range("C" & Rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]With[/COLOR] ListBox1
        [COLOR="Navy"]If[/COLOR] Dn.Value = Sheets("Sheet1").Range("A1") [COLOR="Navy"]Then[/COLOR] .AddItem Dn.Offset(, -2)
    [COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 

Watch MrExcel Video

Forum statistics

Threads
1,129,591
Messages
5,637,288
Members
416,963
Latest member
samfuge

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
Top