Return a range based on a variable

A

Art

Column A contains these five numbers: 9,2,3,5,8
Cell A7 contains the number 4

I need a formula that does the following:
Sum the numbers in column A up to the number of rows in A7.

Formula evaluates to 19 (9+2+3+5)

Thanks,
 
A

Art

Mike, works perfectly.
Would you (or anyone smarter than me) explain how the formula works?
 
M

Mike H

Art,

=SUM(INDIRECT("A1:A" & A7))

INDIRECT treats the bit in quotes as text and then concatenates the value it
finds in A7 to build a valid Excel formula so say A7 contains the number 4
the formula evaluates as

=sum(a1:a4)

what you can't do is this

=sum(a1:a & a7)
you have to use indirect.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top