Attachment 13950See attached, on second sheet (Sheet1 (2)), there's a button which runs a macro.
See comments in the code.
The macro:
Sub blah()
Set myTable = Range("A3").CurrentRegion 'needs the table to be surrounded by blank cells (or the edge of the sheet).
Set DestnHeader = myTable.Rows(1).Find(what:="Destination", Lookat:=xlWhole, LookIn:=xlFormulas, searchformat:=False)
Intersect(DestnHeader.Offset(, 1).EntireColumn, myTable).Insert Shift:=xlToRight
DestnHeader.Offset(, 1).Value = "Type"
TopDataRow = myTable.Row + 1
With DestnHeader.Offset(1, 1).Resize(myTable.Rows.Count - 1)
.FormulaR1C1 = "=IF(SUMPRODUCT((R[-1]C[-2]:R" & TopDataRow & "C[-2]=RC[-1])*(R[-1]C[-1]:R" & TopDataRow & "C[-1]=RC[-2]))>0,""CAT 4"",""CAT 3"")"
.Value = .Value '(removes formulae)
End With
'enable the following 2 lines only if you want to see which rows a Dest/Origin reversal was found on - only applies to your sample sheet:
DestnHeader.Offset(1, 11).FormulaArray = "=MAX(--(R[-1]C[-12]:R4C[-12]=RC[-11])*(R[-1]C[-11]:R4C[-11]=RC[-12])*ROW(R[-1]C[-12]:R4C[-12]))"
DestnHeader.Offset(1, 11).AutoFill Destination:=DestnHeader.Offset(1, 11).Resize(myTable.Rows.Count - 1)
End Sub