trying to create a counta formula using a variable referenced cell.

example
there may be 30 columns, normally you would say =COUNTA(B1:AD1)

in AH1 title how many columns in AH2 contains 24 this time (another user may change this to a different number say 15)

I want to be able to make the forumla COUNTA(B1:{get the reference cell based on what is in AH2, currently it has a value of 24 so I want it to use X1})

is it even possible to do this?
thanks for the help or any other ways to accomplish the same thing!!!

Michelle