VBA dynamic loop

akramer08

Active Member
Joined
May 2, 2012
Messages
265
I have a spreadsheet with 6 columns, A:F. A - order number, B - origin, C - destination, E - movement origin, F - movement destination. It shows what routing the order will take to reach the destination.

For each order there is an origin and destination, and a movement for the flight. The first movement will have to begin at the origin, so col B. The next movement(located on the next row), will have to begin at the destination of the first movement. Examples

1 movement

ID7CVGLAXTT63CVGLAXmovement 1

<tbody>
</tbody>

2 movements

ID12LAXJFKTT34LAXCVGmovement 1
CVGJFKmovement 2

<tbody>
</tbody>

3 movements

ID8CLTLAXTT36CLTGSOmovement 1
GSOCVGmovement 2
CVGLAXmovement 3

<tbody>
</tbody>

There is no set number of rows for each of the orders which is why it will need to recognize how many rows it uses. I need a macro to see if the movements match up. If they dont, then list the ID number on Sheet 2.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
please upload a sample file (with current data and desired result) on a sharing site, then paste the link here
 
Upvote 0
Well here is a table of the data and the desired results

Order

<tbody>
</tbody>
ORG

<tbody>
</tbody>
DST

<tbody>
</tbody>
#

<tbody>
</tbody>
A Org

<tbody>
</tbody>
A Dst

<tbody>
</tbody>
99222201421

<tbody>
</tbody>
CVG

<tbody>
</tbody>
SFO

<tbody>
</tbody>
TTW1

<tbody>
</tbody>
CVG

<tbody>
</tbody>
SFO

<tbody>
</tbody>
99222201185

<tbody>
</tbody>
LAX

<tbody>
</tbody>
CVG

<tbody>
</tbody>
TYH6

<tbody>
</tbody>
LAX

<tbody>
</tbody>
PDX

<tbody>
</tbody>
99222201421

<tbody>
</tbody>
PDX

<tbody>
</tbody>
SFO

<tbody>
</tbody>
TRWS

<tbody>
</tbody>
PDX

<tbody>
</tbody>
CVG

<tbody>
</tbody>
556G

<tbody>
</tbody>
CVG

<tbody>
</tbody>
SFO

<tbody>
</tbody>
99222201185

<tbody>
</tbody>
LAX

<tbody>
</tbody>
BOS

<tbody>
</tbody>
PLM3

<tbody>
</tbody>
LAX

<tbody>
</tbody>
CVG

<tbody>
</tbody>
76TT

<tbody>
</tbody>
DFW

<tbody>
</tbody>
BOS

<tbody>
</tbody>
99222208314

<tbody>
</tbody>
DFW

<tbody>
</tbody>
PDX

<tbody>
</tbody>
HF89

<tbody>
</tbody>
DFW

<tbody>
</tbody>
CVG

<tbody>
</tbody>
0SMD

<tbody>
</tbody>
CVG

<tbody>
</tbody>
BFI

<tbody>
</tbody>
NJV9

<tbody>
</tbody>
BFI

<tbody>
</tbody>
PDX

<tbody>
</tbody>
99222207953

<tbody>
</tbody>
ORD

<tbody>
</tbody>
SJU

<tbody>
</tbody>
HBF9

<tbody>
</tbody>
ORD

<tbody>
</tbody>
CVG

<tbody>
</tbody>
KD8I3

<tbody>
</tbody>
CVG

<tbody>
</tbody>
GSO

<tbody>
</tbody>
01KD

<tbody>
</tbody>
BOS

<tbody>
</tbody>
SJU

<tbody>
</tbody>

<tbody>
</tbody>



RESULTS

99222201185

<tbody>
</tbody>
Loading Error

<tbody>
</tbody>
99222201185

<tbody>
</tbody>
Loading Error

<tbody>
</tbody>
99222201185

<tbody>
</tbody>
Loading Error

<tbody>
</tbody>
99222207953

<tbody>
</tbody>
Loading Error

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,196,120
Messages
6,013,574
Members
441,774
Latest member
esandoval

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