The formula I gave will work, copied down it will give you the result
However you need to adapt it to your situation, does you headers start in
the
Do this test
put 1, 2 and 23 in B1, C1 and D1
then put
=INDEX($B$1:$P$1,,ROWS($A$1:A1))
in A1 and copy down to A3, now in A1 you should get 1, in A2 2 and in A3 3
Now adapt it to your spreadsheet