Look at the image below please:
http://imageshack.us/photo/my-images/89/5ziz.jpg/
Now, let's supposed the distance from A to B is 5 (whatever unit you like). I type A in the first cell, B in the second cell, and the answer 5 pops up in the 5th cell (in this case, we chose the answer to go there). Could work inversely too. B in first cell, A in second, the answer pops up. Now, the question is, where will Excel get the data from?