This spreadsheet aims to calculate distances between atoms, and we want to improve the functions so as to avoid the occupation of extra columns. (See image postscripted.
Atom coordinates are given in the Column A to D, and the atom pair whose distance should be calculated is given in Column F to G.)
Currently in the first step, coordinates of specified atoms are picked up in columns I to O. e.g. Cell I4 is filled with the function:
=VLOOKUP($F4,$A$4:$E$1023,2,FALSE)
and then in the next step, the distance could be resolved in Column Q with Euclidean distance formula on the coordinates picked up. e.g. Cell Q4 is:
=SQRT(POWER((I4-M4),2)+POWER((J4-N4),2)+POWER((K4-O4),2))
According to the distance calculating algorithm, once the two atoms are specified, the distance is then determined. Thus, is it possible to write a function with VBA to gracefully incorporate these functions and take away these pilot processes from columns I to O? (Because these columns will be used otherwise in the future; and the code readability would be terrible if we put, for example, the six VLOOKUP functions directly into the final SQRT function.)
I'm new to VBA. Any help would be appreciated. Thanks!