VBA - Compare cell against matrix with conditions

ComputerMonkey

New Member
Joined
Jun 28, 2016
Messages
2
Hi,

I am scratching my head with this one and hoping to receive some useful insights/help..
Presently I have two datasets, for the purpose of this example let's call them "GPS Data" and "Routes".

GPS data will list every stop a particular truck will stop at throughout the day (i.e. Super Mall, Small Mall, Tiny Mall, Depot). This data contains information for all trucks operating on a single day.

Routes data is a comprehensive list of each route the truck might take. This is determined by where the truck starts, finishes and any specific stops in between.

What I would like to do is take the GPS data (first three fields of sample output in the table below) and align each stop with the corresponding route. I have already developed code to sort the data by date and truck number, I have also stored variables for:
- Trip First Stop Name
- Trip Last Stop Name
- Length of data (Row count)
- Length of Trip (Row count)

The idea was to run loops to compare each stop with the route table to determine the route and store this into a variable, then fill all cells within the desired range with the output of the variable (Route in sample output). However what I am struggling to achieve is how to code VBA to compare the selected loop cell with the table.

Case statement isn't feasible because I will need to compare against a thousand rows of routes.

Any help is good help! :)

Route table
RouteStartFinishBetween1Between2
George Street via PittDepotSuper MartHuge Mart
Hume Hwy via StaceyCollections BSuper MartSmall MartCollections A

<tbody>
</tbody>


Sample Output - Will be using the GPS table (first three fields) and just adding an extra column for the route.
DateTruck NumStopRoute (Desired result)
28/06/2016A-1DepotGeorge Street via Pitt
28/06/2016A-1Small MartGeorge Street via Pitt
28/06/2016A-1Big MartGeorge Street via Pitt
28/06/2016A-1Huge MartGeorge Street via Pitt
28/06/2016A-1Collections AGeorge Street via Pitt
28/06/2016A-1Super MartGeorge Street via Pitt
28/06/2016B-2Collections BHume Hwy via Stacey
28/06/2016B-2Small MartHume Hwy via Stacey
28/06/2016B-2Collections AHume Hwy via Stacey
28/06/2016B-2Super MartHume Hwy via Stacey

<tbody>
</tbody>
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi,

Can you explain how 7 entries are coming for George Street via Pitt and 4 for Hume Hwy via Stacey in GPS table.

Collections A, Small Mart, Big Mart don't exists in Route table for George Street.
 
Upvote 0
Hi,

Can you explain how 7 entries are coming for George Street via Pitt and 4 for Hume Hwy via Stacey in GPS table.

Collections A, Small Mart, Big Mart don't exists in Route table for George Street.

The Routes table will only look at specific stops, the major locations to determine a route.
i.e. only the "George Street via Pitt" route will have the Origin, Destination and Via pairing of "Depot, Huge Mart, Super Mart"

Sometimes 2 "between" stops are required to differentiate between two different routes. There will be a specific route for each service.
 
Upvote 0

Forum statistics

Threads
1,215,728
Messages
6,126,523
Members
449,316
Latest member
sravya

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