Hello again,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
I have on a sheet a list of cities (in MN, WI, IL and both Dakotas) where physicians travel to do exams. Users can filter those cities. On a second hidden sheet, I have a database of all US cities, their state, zip code and latitude/longitude coordinates.<o></o>
I need to code a cell on the first sheet so that users can enter any zip code and Excel returns a list of all US cities within 150 miles in an adjacent cell. <o></o>
I already have the function to calculate the distance (in miles) between two sets of coordinates:<o></o>
My thoughts: The user-input zip will need to vlookup the zip column + latitude / longitude columns of the database; run the function above using that set of coordinate as Lat1 and Long1, and calculate all results using the coordinates for all the other US cities as Lat2 and Long2 (33,178 cities total) - and finally return the names of all the cities that fall within 150 miles of the original zip code in the cell adjacent to the one where the user input the zip code<o></o>
How the heck would you code that?<o></o>
Thank as always. this forum is a precious source of help!
I have on a sheet a list of cities (in MN, WI, IL and both Dakotas) where physicians travel to do exams. Users can filter those cities. On a second hidden sheet, I have a database of all US cities, their state, zip code and latitude/longitude coordinates.<o></o>
I need to code a cell on the first sheet so that users can enter any zip code and Excel returns a list of all US cities within 150 miles in an adjacent cell. <o></o>
I already have the function to calculate the distance (in miles) between two sets of coordinates:<o></o>
=ACOS(COS(RADIANS(90-Lat1)) *COS(RADIANS(90-Lat2)) +SIN(RADIANS(90-Lat1)) *SIN(RADIANS(90-Lat2)) *COS(RADIANS(Long1-Long2))) *3958.756<o></o>
My thoughts: The user-input zip will need to vlookup the zip column + latitude / longitude columns of the database; run the function above using that set of coordinate as Lat1 and Long1, and calculate all results using the coordinates for all the other US cities as Lat2 and Long2 (33,178 cities total) - and finally return the names of all the cities that fall within 150 miles of the original zip code in the cell adjacent to the one where the user input the zip code<o></o>
How the heck would you code that?<o></o>
Thank as always. this forum is a precious source of help!