[excel] Using the value in a cell as a cell reference in a formula?

I'd like to know how to pull cell references from the value of another cell and insert them into a formula.

For a simple example:

In cell A1 I have this: COUNT(B4:H4)

Instead of choosing the range when I set up the formula, I'd like this range to be dynamic, based on the value in other cells.

So, I want to type in cell references: in cell B4, I'd type in C5, and in H4 I'd type in C8. How can I set up my formula to look inside cells B4 and H4, but then return the range that is defined by the values in these cells (C5:C8 in this case...) So in the end, cell A1 would return the count of C5:C8

I hope that makes sense. It seems like something pretty simple but I can't seem to find info on it. Thanks in advance.

This question is related to excel excel-formula

The answer is


Use INDIRECT()

=SUM(INDIRECT(<start cell here> & ":" & <end cell here>))