3. října 2010

How to calc distance between places in Google Spreadsheet

This week I  got email from Steve. He has a problem with my Google Spreadsheet function getDistance. So I have decided to write short tutorial, how to use this useful function
We have matrix with cities. Now we woud like to calculate distance between each other.


1.) After created a new Google Spreadsheet, select menu item Insert > Script

2.) Script Gallery is fullfilled functions from crowd. Search keyword "getdistance" (or "codeasi" :)



3.) Now you have to authorize this function (don't worry)


4.) Create matrix with places.


Hint: use this pattern: place, country for example:  
  • Hastings, United Kingdom
  • Vaclavske namesti 3, Ceska republika



5.) Write function to cell B3: =getDistance($A3,B$2)
In this case char "$" means:
  • $A3 -> after copying to other cells the first position of address is not added (it is still "A" and refer to places in column A)
  • B$2 -> after copying to other cells the seconds position of address is not added (it is still "2" a refer to places in second row)




6.) After all will happen the coolest&sexiest thing :) just copying to other cells




7.) Voilá, result :) Returned numbers are in km



Zajímá tě více?