Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sum Range of Cells to a Target Value

I need to sum a range of cells until a taget value is reached or just
under target value is reached. Once I have reached the target, I
would like to get the cell address of tthe cell directly above that
point.

Simplified Example:
A1:F1 contains Jan, Feb, Mar, Apr, May, Jun
A2:F2 contains 2, 4, 7, 3, 1, 5

A5 contains the target, 16

I need the output to indicate "Apr" or the cell address "D1"

I can do this in VBA; however in this instance, I would prefer to use
cell-based formulas. I have tried to use array formulas, but with no
success. Any ideas?

Any help would be appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Sum Range of Cells to a Target Value

very easy with a helper row.

in A3 enter
=A2
in B3 enter
=IF(A3+B2<=$A$5,A3+B2,-99999) and copy across

to see:

jan feb mar apr may jun
2 4 7 3 1 5
2 6 13 16 -99999 -99994


in any cell enter
=OFFSET(A1,,MATCH(MAX(3:3),3:3,1)-1)

--
Gary''s Student - gsnu200729


" wrote:

I need to sum a range of cells until a taget value is reached or just
under target value is reached. Once I have reached the target, I
would like to get the cell address of tthe cell directly above that
point.

Simplified Example:
A1:F1 contains Jan, Feb, Mar, Apr, May, Jun
A2:F2 contains 2, 4, 7, 3, 1, 5

A5 contains the target, 16

I need the output to indicate "Apr" or the cell address "D1"

I can do this in VBA; however in this instance, I would prefer to use
cell-based formulas. I have tried to use array formulas, but with no
success. Any ideas?

Any help would be appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sum Range of Cells to a Target Value


Many Thanks. I see how this works in the example I provided. If I
change the target to say, 13, then I get "June" as a response, not
"Mar". This appears to be due to the subtraction of 1 from the column
argument of the OFFSET function, correct? Is there a way to make it
solvable for whatever the target is (within reason)?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Sum Range of Cells to a Target Value

The subtraction of one is O.K. My error was using 1 as the last argument of
MATCH.

Here is the corrected formula:

=OFFSET(A1,,MATCH(MAX(3:3),3:3,0)-1)

sorry
--
Gary''s Student - gsnu200729


" wrote:


Many Thanks. I see how this works in the example I provided. If I
change the target to say, 13, then I get "June" as a response, not
"Mar". This appears to be due to the subtraction of 1 from the column
argument of the OFFSET function, correct? Is there a way to make it
solvable for whatever the target is (within reason)?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sum Range of Cells to a Target Value

On Jun 14, 2:14 pm, Gary''s Student
wrote:
The subtraction of one is O.K. My error was using 1 as the last argument of
MATCH.

Here is the corrected formula:

=OFFSET(A1,,MATCH(MAX(3:3),3:3,0)-1)

sorry
--
Gary''s Student - gsnu200729


Not a problem. I appreciate the assistance.



  #6   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Sum Range of Cells to a Target Value

In another post, Harlan constructed a formula which returns an array of
subtotals - which I believe can be used for your purposes.

=INDEX(A1:F1,MATCH(A5,MMULT(--(TRANSPOSE(COLUMN(A2:F2))=COLUMN(A2:F2)),TRANSPOS E(A2:F2)),1))

array entered.


" wrote:

On Jun 14, 2:14 pm, Gary''s Student
wrote:
The subtraction of one is O.K. My error was using 1 as the last argument of
MATCH.

Here is the corrected formula:

=OFFSET(A1,,MATCH(MAX(3:3),3:3,0)-1)

sorry
--
Gary''s Student - gsnu200729


Not a problem. I appreciate the assistance.


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
Can you use a Range $N$xx:$Q$xx in Target.Address? CRayF Excel Programming 7 December 14th 06 09:11 PM
Target As Excel.Range or Target As Range Piranha[_5_] Excel Programming 2 June 3rd 05 03:49 PM
Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range) Kevin McCartney Excel Programming 3 April 15th 05 01:51 PM
ByVal Target As Range monir Excel Programming 4 April 12th 05 04:37 PM
Help - loop through cells in a range that are not together (several different cells as Target) Marie J-son[_5_] Excel Programming 4 April 3rd 05 09:54 PM


All times are GMT +1. The time now is 03:22 AM.

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

About Us

"It's about Microsoft Excel"