Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel formula

Status
Not open for further replies.

methoni

Technical User
Jan 16, 2002
22
0
0
US
I am looking to set up a formula that would add a certain number of consecutive cells in a table based on an input.
For example; cell A2 will have an entry. Based on a lookup of that entry, I would like cell B2 to be the sum of G2:?2.
Si, if cell A2 = 6, then B2 should be sum of G2:L2.

Lookup cell A2 in "table" below to get the appropriate sum in cell B2.

Table:
1 G2:G2
2 G2:H2
3 G2:I2
4 G2:J2
5 G2:K2
6 G2:L2

Thanks for your help,

DT

BTW, I prefer a formula instead of a macro.
 
You don't say what should happen if A2 is left blank or is zero. But something like this should work:
[tab][COLOR=blue white]=SUM(INDIRECT(ADDRESS(2,7)&":"&ADDRESS(2,6+$A$2)))[/color]

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 


Hi,

Take a look at the OFFSET function. It will return a RANGE. vary the WIDTH (number of columns) in the range, with the 5th argument.

Skip,
[sub]
[glasses] [red]Be Advised![/red] The only distinction between a bird with one wing and a bird with two, is merely...
a difference of A Pinion! [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top