Hi all!

First post, so bear with me.....

I've got a spreadsheet that compares two postcodes and calculates the distance between them. The code I'm using is
=IF($B$31="",0,(SQRT((VLOOKUP(LEFT($B$31,4),'Postcode data'!$A$2:$C$3221,2)-VLOOKUP(LEFT(A31,4),'Postcode data'!$A$2:$C$3221,2))^2+((VLOOKUP(LEFT($B$31,4),'Postcode data'!$A$2:$C$3221,3)-VLOOKUP(LEFT(A31,4),'Postcode data'!$A$2:$C$3221,3))^2))/1000)/1.6093)
This works fine, but the problem is I've got over 3,200 different rows of postcodes to check and also need to do it for 92 different postcodes. Meaning I have to check the distances of 92 different postcodes from each of the 3,200. If that makes any more sense!

Anyway, what I need to do is change the part of the code that says
(A31,4)
in the above code, and change it to
($D$2,4)
Obviously for each row, the cell number changes.

Is there a quick way of me being able to change this part of the formula for all the rows in the spreadsheet, or have I got to do it all manually?