Hi Experts,

I have a logical problem which i am able to solve in SQL but for user experience it has to be given as a VBA macro solution.There is a excel which has source and destination data as given below, and there is a need to identify any circular loop being formed in data. Circular loop being referred to a situation where a source is mapped to a destination in a row, while in another row destination maps back to same source (As in row number 7 & 9). There can be stepped loop too (as in row number 3, 4, 5, 6. A->B B->C C->D D->A).

I have approached it by looking up for each source value in targets column and if it exists in target, make the source value corresponding to the match a new lookup value, do it till i reach the target of original source from where we started.
This logic fails when it gets multiple matches for a lookup value (as in row no. 2, 6 for source A), even though i am using index/match instead of vlookup.

S.NO. Source Destination
1 Y Z
2 C A
3 A B
4 B C
5 C D
6 D A
7 T U
8 E X
9 U T