My question builds off of the one asked here and the accepted answer:
Find the nearest set of coordinates in Excel
The accepted answer there provides two solutions:
- Non-circular distance:
=LOOKUP(1,1/FREQUENCY(0,MMULT((B$1:C$10-E1:F1)^2,{1;1})),A$1:A$10) - Circular distance:
=LOOKUP(1,1/FREQUENCY(0,SIN((RADIANS(B$1:B$10-E1))/2)^2+SIN((RADIANS(C$1:C$10-F1))/2)^2*COS(RADIANS(B$1:B$10))*COS(RADIANS(E1))),A$1:A$10)
However, that dataset looks like this:
I'm trying to work with a dataset that looks like the following:
What I'm trying to do is:
- Fill in
GandHwhere they are empty. - If
GandHis empty, look atEandF(e.g.G2andH2are empty, so get the coordinates fromE2andF2). - Search all
EandFfor the next closest coordinates whereGandHare not blank. - Return the value of
GandH.
All I have so far is modifying the Non-circular solution:
=LOOKUP(1,1/FREQUENCY(0,MMULT(($E$2:$F$69778-E2:F2)^2,{1;1})),$H$2:$H$69778)
Of course with this, it just matches to itself and G and H are blank so it returns nothing.
Any suggestions for how to implement this?
As a last resort I can always just copy to a separate tab all of the rows with values in G and H and do the lookup against that. Trying to implement it without doing that first however.


