I want Excel to check intervals in all the lines in another sheet, finally returning true if my value is in any of those intervals, and fetching a value in that given line if true.

Let's call the value to be tested "X". I want Excel to check if X is between the values in cells A# and B#, returning the string in cell C# if true, or "" if ultimately false. That's simple enough to visualize as an IF function. My problem is that also I want the program to automatically check A#+1 and B#+1, returning C#+1, if the first check is false, A#+2 and B#+2, returning C#+2, if the second check is false, and so on. I'm dealing with sheets with more than a thousand lines, so it wouldn't be practical to just embed multiple IF statements in the formula.

That seems to be somehow possible with ARRAY or CSE functions, but I have no experience with them, and frankly couldn't figure out how to do it by myself, in any case.

Can you guys think of a way to do that using only Excel?