adding variable number of columns

G

Guest

Hi,

Can you add a variable number of columns?
I have a value in cell A1 which can be a number between 1 and 12.
In cell B1 I want a formula which will give:
If A1 = 1, B1 = A2
If A1 = 2, B1 = A2+B2
If A1 = 3, B1 = A2+B2+C2
If A1 = 4, B1 = A2+B2+C2+D2...etc
is there a way to say B2 = A2 plus n cells in the same row, where n is the
vvalue in cell A1?

thanks for any help you can give!
cheers
 
J

Jay

Can you add a variable number of columns?
I have a value in cell A1 which can be a number between 1 and 12.
In cell B1 I want a formula which will give:
If A1 = 1, B1 = A2
If A1 = 2, B1 = A2+B2
If A1 = 3, B1 = A2+B2+C2
If A1 = 4, B1 = A2+B2+C2+D2...etc
is there a way to say B2 = A2 plus n cells in the same row, where n is
the value in cell A1?


One way:
=SUM(A2:INDIRECT(CHAR(CODE("A")+A1)&2))
 

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