#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Sum Columns

Hi All,

I have the Following in my worksheet

A1 contains a month end date for eg. 30-04-05

B2 C2 ..... AK2 AM2
31-1-03 28-2-03 ..... 31-12-05 TOTAL
100 250 ..... 425 xxxx
250 150 ..... 200 xxxx

I want to get the total based on the date in my A1. For eg if A1
containd 31-3-04 in my AM3 the total shud be sum(B3:P3) (31-01-03 to
31-03-04)

so when ever I change the date in my A1 my total column shud take from
31-1-03 up to the column in which the same date appears.

Is there an easy way to acheive this either thru code or formulae?

thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Sum Columns

=SUM(OFFSET($B3,,,,MATCH($A$1,2:2,0)-1))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Soniya" wrote in message
oups.com...
Hi All,

I have the Following in my worksheet

A1 contains a month end date for eg. 30-04-05

B2 C2 ..... AK2 AM2
31-1-03 28-2-03 ..... 31-12-05 TOTAL
100 250 ..... 425 xxxx
250 150 ..... 200 xxxx

I want to get the total based on the date in my A1. For eg if A1
containd 31-3-04 in my AM3 the total shud be sum(B3:P3) (31-01-03 to
31-03-04)

so when ever I change the date in my A1 my total column shud take from
31-1-03 up to the column in which the same date appears.

Is there an easy way to acheive this either thru code or formulae?

thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Sum Columns

Hi Soniya!

first:
use a cell with a formula to find the the date in row2
B1 =MATCH(a1,2:2,0)

then:
you need indirect or offset function.
the offset function has 5 arguments

range,moveR,moveC,height,width

let's set the 'starting range' at b3.
we're not "moving" it, just "sizing" so argument 2/3 will be zero.
b1 holds position so we must create the width by deducting 1

AM3 =SUM(OFFSET($B3,0,0,1,$B$1-1)

try it..

....

got it?

now it's also easy to adapt the formulas
so you can sum from/to.

you'll need a cell with the From position.
you'll need a cell with the Thru position.

assume a1 is date from
assume b1 is date thru
c1 (position from) =MATCH(a1,2:2,0)
d1 (position thru) =MATCH(b1,2:2,0)

am3 = =SUM(OFFSET($A3,0,$C$1,1,$D$1-$C$1+1)

(i hope i got all the plus/minus 1 correct..
as i'm typing "off the cuff")




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Soniya wrote :

Hi All,

I have the Following in my worksheet

A1 contains a month end date for eg. 30-04-05

B2 C2 ..... AK2 AM2
31-1-03 28-2-03 ..... 31-12-05 TOTAL
100 250 ..... 425 xxxx
250 150 ..... 200 xxxx

I want to get the total based on the date in my A1. For eg if A1
containd 31-3-04 in my AM3 the total shud be sum(B3:P3) (31-01-03 to
31-03-04)

so when ever I change the date in my A1 my total column shud take from
31-1-03 up to the column in which the same date appears.

Is there an easy way to acheive this either thru code or formulae?

thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Sum Columns

Fantastic.. and worked well.... thanks for all the reply..

thanks again

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
Make Columns A&B on Sheet2 always equal Sheet1 table columns A&B KnightBall Excel Worksheet Functions 6 August 18th 09 05:48 PM
Combine multiple columns into two long columns, Repeating rows in first column [email protected] Excel Discussion (Misc queries) 2 July 31st 06 09:45 PM
Combine multiple columns into two long columns, Repeating rows in first column [email protected] Excel Discussion (Misc queries) 0 July 31st 06 05:07 PM
Excel button :: Filter columns by value - possible? Additionally, hide certain columns No Name Excel Programming 4 December 28th 04 07:44 PM
Pivot Table Creating New Columns that Subtract Two Existing Columns den4673 Excel Discussion (Misc queries) 3 December 17th 04 01:31 PM


All times are GMT +1. The time now is 01:20 AM.

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"