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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

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