I have the table below. I want to lookup the column header a number is between numbers based on the name in column A. So, if I look up "Dog" and "3.5" then I want it to return "B". The best formula I have come up with is
=INDEX(L1:M6,COLUMN(INDEX(A1:G5,MATCH(J2,A1:A5,0),MATCH(J3,B2:G2,-1))),2)
However, it's not working great. First, I had to create a separate table to indicate the column returned to get the column header. Also, I can't figure out how to make it change the row it looks the number in. Third, i can only make it work using the number in the row as the upper bound ex. "3.5" returns "#N/A" instead of "B".
=INDEX(L1:M6,COLUMN(INDEX(A1:G5,MATCH(J2,A1:A5,0),MATCH(J3,B2:G2,-1))),2)
I want to return "B", not "#N/A". Also I want it not have to rely on the first index function. Ideally the formula looks something like this?
=INDEX(A1:G5,MATCH(J2,A1:A5,0),MATCH(J3,B2:G2,-1))

Try using
XLOOKUP()function here: