VLOOKUP function within Great Circle Distance calculation function

greg1075

Board Regular
Joined
Oct 7, 2011
Messages
98
I'm slowly trying to make way in my distance calculation project...

Here is the current problem.

I have function in order to calculate as-the-crow flies distance between two sets of coordinates.

=6371*((2*ASIN(SQRT((SIN((RADIANS(Lat1)-RADIANS(Lat2))/2)^2)+ COS(RADIANS(Lat1))*COS(RADIANS(Lat2))*(SIN((RADIANS(Long1)-RADIANS(Long2))/2)^2)))))

The Lat1 and Long1 values will be on the same worksheet as the above function (columns B and C) so it's an easy point and click:


scrnsht.jpg



However I need the Lat2 and Long2 values to be populated via user entering a zipcode in cell E109 of the "Minnesota" worksheet . I have thus come up with a VLOOKUP:

(=VLOOKUP(Minnesota!E109,zipcodes!A:C,2,FALSE)
for Lat2

(=VLOOKUP(Minnesota!E109,zipcodes!A:C,2,FALSE)
for Long2


giving me the following final function:

=6371*((2*ASIN(SQRT((SIN((RADIANS(=VLOOKUP(Minnesota!E109,zipcodes!A:C,2,FALSE))-RADIANS(zipcodes!B2))/2)^2)+COS(RADIANS(=VLOOKUP(Minnesota!E109,zipcodes!A:C,2,FALSE)))*COS(RADIANS(zipcodes!B2))*(SIN((RADIANS(=VLOOKUP(Minnesota!E109,zipcodes!A:C,3,FALSE))-RADIANS(zipcodes!C2))/2)^2)))))
However Excel tells me the formula above contains an error. Any idea why? Is having a few VLOOKUPs within the original function not possible?

Thanks!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try removing the "="-signs before the VLOOKUP functions.
 
Upvote 0

Forum statistics

Threads
1,222,121
Messages
6,164,079
Members
451,870
Latest member
Nikhil excel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top