Help populating a combo box in VB

apgriffiths

Board Regular
Joined
Jun 2, 2006
Messages
99
Hi i have a form with two combo boxes, one that specifies a date and one that specifies a location. I also have a third combo box that i want to populate with a corressponding list from a worksheet eg,
Book1
ABCD
1DateLocationNameLocationRefRoute
212/05/2008Aberdeen16630
312/05/2008Aberdeen1663101
412/05/2008Aberdeen1663102
512/05/2008Aberdeen1663103
612/05/2008Aberdeen1663104
713/05/2008Aberdeen1663105
813/05/2008Aberdeen1663106
913/05/2008Aberdeen1663107
1013/05/2008Aberdeen1663108
1113/05/2008Aberdeen1663109
1214/05/2008Aberdeen1663110
1314/05/2008Aberdeen1663111
1414/05/2008Aberdeen1663112
1514/05/2008Aberdeen1663208
1614/05/2008Aberdeen1663422
1714/05/2008Aberdeen1663581
Sheet1


When i selct the date and location from the first two combo boxes i want the third to only show me the available routes for that location on that day.

I already have the following code for adding items to a lcombo box,<font face=Courier New><SPAN style="color:#00007F">Public</SPAN><SPAN style="color:#00007F">Sub</SPAN> AddItems()<br><SPAN style="color:#00007F">Dim</SPAN> AllCells<SPAN style="color:#00007F">As</SPAN> Range, Cell<SPAN style="color:#00007F">As</SPAN> Range<br><SPAN style="color:#00007F">Dim</SPAN> NoDupes<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">New</SPAN> Collection<br><br>    <SPAN style="color:#00007F">On</SPAN><SPAN style="color:#00007F">Error</SPAN><SPAN style="color:#00007F">Resume</SPAN><SPAN style="color:#00007F">Next</SPAN><br>    <br>    <SPAN style="color:#00007F">Set</SPAN> AllCells = Sheets("Sheet1").Range("A1:D10")<br>    <br>    <SPAN style="color:#00007F">For</SPAN><SPAN style="color:#00007F">Each</SPAN> Cell<SPAN style="color:#00007F">In</SPAN> AllCells<br>        NoDupes.Add Cell.Value,<SPAN style="color:#00007F">CStr</SPAN>(Cell.Value)<br>    <SPAN style="color:#00007F">Next</SPAN> Cell<br>    <br>    <SPAN style="color:#00007F">For</SPAN><SPAN style="color:#00007F">Each</SPAN> Item<SPAN style="color:#00007F">In</SPAN> NoDupes<br>        cbCombo.AddItem Item<br>    <SPAN style="color:#00007F">Next</SPAN> Item<br>    <br><SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN></FONT>

How do i manage to just pick out the selected date and location??
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Watch MrExcel Video

Forum statistics

Threads
1,129,754
Messages
5,638,170
Members
417,011
Latest member
Amaden95

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