You need to lookup the value which is associated with both location codes. I've used an array formula which allows you to take the lookup value (combination of the two location codes - GH MM) and search for a match when the distance sheet shows that combination. A normal formula won't allow you to string together the distance sheets columns. The IF part checks to see if the two codes are the same and returns 0 miles if they are, then the iferror parts say look for GH MM, if no match, try MM GH and if no match, say "No Match".
Array formulas must be entered by typing the formula and then using ctrl-shift-enter. However, as with other formula types you can drag the formula down to fill new cells and rows as normal.
Array formulas must be entered by typing the formula and then using ctrl-shift-enter. However, as with other formula types you can drag the formula down to fill new cells and rows as normal.