Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
gr gr is offline
external usenet poster
 
Posts: 3
Default Sum by variable column

I am having trouble wrapping my brain around this one.

I have a listing of columns for months (in reverse order). In each row
is that months budget numbers. What I want to do is have a column that
sums the year to date based on a value that is typed into a cell.
Colunn U = Jan
column T = Feb
Column S = March
etc

So if I type a 1, I want the sum of row x columns U:U
If I type a 3, I want the sum of row x columns S:U
etc

Thanks in advance for any help.
Guy

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 301
Default Sum by variable column

If that number is in cell A1, for example, this formula will do what you
want (fill down):
=SUM(OFFSET(J2,0,12-A1,1,A1))

"gr" wrote in message
oups.com...
I am having trouble wrapping my brain around this one.

I have a listing of columns for months (in reverse order). In each row
is that months budget numbers. What I want to do is have a column that
sums the year to date based on a value that is typed into a cell.
Colunn U = Jan
column T = Feb
Column S = March
etc

So if I type a 1, I want the sum of row x columns U:U
If I type a 3, I want the sum of row x columns S:U
etc

Thanks in advance for any help.
Guy



  #3   Report Post  
Junior Member
 
Location: Coos Bay, OR
Posts: 2
Send a message via Skype™ to Rand451
Default

I put the months in row 2, columns J to U. With U2 = Jan

Cell A2 is reserved for the number of columns. Recommend you use data validation or some kind of drop-down list to restrict the user to 12 max.

x values go in B3 to whatever

The following formula was filled down from A3 to whatever

=SUM(OFFSET($U$2,$B3,1,1,1):OFFSET($U$2,$B3,-$A$2+1,1,$A$2))

$U$2 = Jan
$B3 = x = this row, column 2
$A$2 = # months

in R1C1 notation: =SUM(OFFSET(R2C21,RC2,1,1,1):OFFSET(R2C21,RC2,-R2C1+1,1,R2C1))

hth...

Quote:
Originally Posted by gr
I am having trouble wrapping my brain around this one.

I have a listing of columns for months (in reverse order). In each row
is that months budget numbers. What I want to do is have a column that
sums the year to date based on a value that is typed into a cell.
Colunn U = Jan
column T = Feb
Column S = March
etc

So if I type a 1, I want the sum of row x columns U:U
If I type a 3, I want the sum of row x columns S:U
etc

Thanks in advance for any help.
Guy
  #4   Report Post  
Junior Member
 
Location: Coos Bay, OR
Posts: 2
Send a message via Skype™ to Rand451
Default

Guy's solution is better than mine...

I made a minor change to it: =SUM(OFFSET($U$2,$B3,-$A2+1,1,$A$2))

$U$2 = Jan
$B3 = x value
$A2 = # of months

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro unouwanme Excel Discussion (Misc queries) 9 August 31st 06 09:38 PM
Need to Improve Code Copying/Pasting Between Workbooks David Excel Discussion (Misc queries) 1 January 6th 06 03:56 AM
Positioning Numeric Values Resulting from 6 Column Array Formula Sam via OfficeKB.com Excel Worksheet Functions 2 January 5th 06 02:03 AM
Can the column index in a cell address be made variable? cyberdude Excel Discussion (Misc queries) 1 November 20th 05 02:47 AM
Putting text in a column based on variable text from another colum Jacky D. Excel Discussion (Misc queries) 1 December 16th 04 06:09 PM


All times are GMT +1. The time now is 05:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"