I don't think you make one formula to tell how much you need to lag in order to achieve a correlation of 1; it would quickly become cumbersome in any case. But you could alter MarvinP's formula in B5 to:

=CORREL(A2:L2,$A$3:$L$3) and copy across instead of down.

And then create a formula that returns the lag which will give you the highest correlation coefficient, and then go from there.