Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Summming a Data range through a cutoff date ?

How do I sum a Data range through a cutoff date ?
I thought I had submitted a common problem but got no response.
..
I have a varying CutOff Date in cell B1 currently equal to 8/23 (after
formatting).
The calendar starts in C2, last Column unknown.
The Data itself starts in Row 3, Last row unknown.
..
I want to loop through each row and fill in the column B
the sum of the range from Column C through the Cutoff Date Column.
..
The expected result in Column B (Done)
will be 80 for Item Y and 400 for Item Z.
..
Cut off Date : 8/23
Item Done 8/21 8/22 8/23 8/24 8/25 ...
Y 80 60 20 40
Z 400 140 100 160 120 180 ...

....
....
Can you help me ?
Thank you,
Celeste

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Summming a Data range through a cutoff date ?

What you have is essentially a sum for a range that will chage dynamically
based on the cuttoff date.
I can't think of any way to do this other than doing a user defined
function... here is my crack at it.

Public Function SumBeforeCutOff(RangeToSum As Range, DateRange As Range,
CutOffDate As Date) As Double
'Like vLookUp function, this assumes that RangeToSum and DateRange are
the same size and are aligned, and in this case are both only 1 row high
Dim c As Range
Dim DateRow As Long
Dim RangeRow As Long
Dim DateRowOffset As Long

Application.Volatile

DateRow = DateRange.Row
RangeRow = RangeToSum.Row
DateRowOffset = DateRow - RangeRow

For Each c In RangeToSum
If c.Offset(DateRowOffset) <= CutOffDate Then
SumBeforeCutOff = SumBeforeCutOff + c
End If
Next

End Function

This needs to be put in a code module (not an excel object)
Then, to use your example, the cell where the sum needs to be would have a
formula sortof like this: =SumBeforeCutOff(C3:F3,C$2:F$2,B$1) or if you want
to use all possible columns =SumBeforeCutOff(C3:IV3,C$2:IV$2,B$1)

This seem to work for you particular example... but there is no error
checking and all dates must be actal date values.

Also, it won't care if the dates are in order... so in fact, you could add
another column at the end, and if the date in the header in before the cutoff
date, the value will be included in the sum.

Hope this helps.

"u473" wrote:

How do I sum a Data range through a cutoff date ?
I thought I had submitted a common problem but got no response.
..
I have a varying CutOff Date in cell B1 currently equal to 8/23 (after
formatting).
The calendar starts in C2, last Column unknown.
The Data itself starts in Row 3, Last row unknown.
..
I want to loop through each row and fill in the column B
the sum of the range from Column C through the Cutoff Date Column.
..
The expected result in Column B (Done)
will be 80 for Item Y and 400 for Item Z.
..
Cut off Date : 8/23
Item Done 8/21 8/22 8/23 8/24 8/25 ...
Y 80 60 20 40
Z 400 140 100 160 120 180 ...

....
....
Can you help me ?
Thank you,
Celeste


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
Cutoff Time for Changes DOUG Excel Discussion (Misc queries) 4 May 6th 09 01:50 PM
Cutoff score for acceptance [email protected] Excel Worksheet Functions 5 August 13th 08 12:49 AM
Text is cutoff in a cell Jessica Excel Discussion (Misc queries) 5 September 6th 07 03:26 AM
Excel "Value (Y) Axis" is cutoff--Fix it! gian Charts and Charting in Excel 0 September 21st 05 03:45 AM
CUTOFF Ahmad Excel Discussion (Misc queries) 5 March 5th 05 08:32 PM


All times are GMT +1. The time now is 08:30 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"