I am working on a tool to determine the 5 closest locations to a zip code. The user will enter a zip code on the "Main Page" in C5 and the 5 closest locations on page 2 will populate in column F 4:8. I am using the following to determine the distance between zip codes:
=6371*2*ASIN(SQRT(SIN((RADIANS('Main Page'!$C$8)-RADIANS(Table2[@Column4]))/2)^2+COS(RADIANS('Main Page'!$C$8))*COS(RADIANS(Table2[@Column4]))*SIN((RADIANS(Table2[@Column3])-RADIANS('Main Page'!$C$7))/2)^2))
I then use math to convert to miles, because, well, the USA. Using
=SMALL(Sheet2!P:P,{1;2;3;4;5})
to get my five closest locations works great, most of the time. It is when I have a zip code with multiple locations that the results are skewed. Due the "tie" I get results that are duplicated and others are omitted. What can I use in place of =SMALL to give me the results when a specific zip code has "ties"
The other problem I am running into is that C5 on the main page is a Geography Data Type. Excel does not like East coast zip codes that begin with 0. If I use a zip code for Trenton, NJ, 08601, it does not return a result because the beginning 0 gets dropped. If I use '08601, then the Geography Data Type gets erased. Any ways around this?
=6371*2*ASIN(SQRT(SIN((RADIANS('Main Page'!$C$8)-RADIANS(Table2[@Column4]))/2)^2+COS(RADIANS('Main Page'!$C$8))*COS(RADIANS(Table2[@Column4]))*SIN((RADIANS(Table2[@Column3])-RADIANS('Main Page'!$C$7))/2)^2))
I then use math to convert to miles, because, well, the USA. Using
=SMALL(Sheet2!P:P,{1;2;3;4;5})
to get my five closest locations works great, most of the time. It is when I have a zip code with multiple locations that the results are skewed. Due the "tie" I get results that are duplicated and others are omitted. What can I use in place of =SMALL to give me the results when a specific zip code has "ties"
The other problem I am running into is that C5 on the main page is a Geography Data Type. Excel does not like East coast zip codes that begin with 0. If I use a zip code for Trenton, NJ, 08601, it does not return a result because the beginning 0 gets dropped. If I use '08601, then the Geography Data Type gets erased. Any ways around this?