Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum of a Range (with a twist)


Is there a formula that allows me to sum the values in a variable Range,
whereby a fixed amount is subtracted from each value in the Range?

e.g. Column A contains the following data:

A1 Amount
A2 10
A3 -5

The value of cell B1 has to be subtracted from each value in the A
range.
B1 contains 1.

So the expected value should be: 9 + (-6) = 3

Using the (array) formula
-{=SUM(OFFSET($A$2,0,0,COUNTA($A:$A)-1,1)-$B$1)} - produces the
unexpected answer -2! The non-array version produces a #VALUE error.


--
rvExcelNewTip
------------------------------------------------------------------------
rvExcelNewTip's Profile: http://www.excelforum.com/member.php...o&userid=15668
View this thread: http://www.excelforum.com/showthread...hreadid=376699

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Sum of a Range (with a twist)

Try:

=SUM(A:A)-COUNTA(A:A)*$B$1

HTH

"rvExcelNewTip" wrote:


Is there a formula that allows me to sum the values in a variable Range,
whereby a fixed amount is subtracted from each value in the Range?

e.g. Column A contains the following data:

A1 Amount
A2 10
A3 -5

The value of cell B1 has to be subtracted from each value in the A
range.
B1 contains 1.

So the expected value should be: 9 + (-6) = 3

Using the (array) formula
-{=SUM(OFFSET($A$2,0,0,COUNTA($A:$A)-1,1)-$B$1)} - produces the
unexpected answer -2! The non-array version produces a #VALUE error.


--
rvExcelNewTip
------------------------------------------------------------------------
rvExcelNewTip's Profile: http://www.excelforum.com/member.php...o&userid=15668
View this thread: http://www.excelforum.com/showthread...hreadid=376699


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Sum of a Range (with a twist)

Sorry .. to allow for header ...

=SUM(A:A)-(COUNTA(A:A)-1)*$B$1


"Toppers" wrote:

Try:

=SUM(A:A)-COUNTA(A:A)*$B$1

HTH

"rvExcelNewTip" wrote:


Is there a formula that allows me to sum the values in a variable Range,
whereby a fixed amount is subtracted from each value in the Range?

e.g. Column A contains the following data:

A1 Amount
A2 10
A3 -5

The value of cell B1 has to be subtracted from each value in the A
range.
B1 contains 1.

So the expected value should be: 9 + (-6) = 3

Using the (array) formula
-{=SUM(OFFSET($A$2,0,0,COUNTA($A:$A)-1,1)-$B$1)} - produces the
unexpected answer -2! The non-array version produces a #VALUE error.


--
rvExcelNewTip
------------------------------------------------------------------------
rvExcelNewTip's Profile: http://www.excelforum.com/member.php...o&userid=15668
View this thread: http://www.excelforum.com/showthread...hreadid=376699


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum of a Range (with a twist)


thanks folks! basic algebra, I should have thought of

--
rvExcelNewTi
-----------------------------------------------------------------------
rvExcelNewTip's Profile: http://www.excelforum.com/member.php...fo&userid=1566
View this thread: http://www.excelforum.com/showthread.php?threadid=37669

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Sum of a Range (with a twist)

I don't know why, but my first post didn't come through. Try the same
as Toppers but account for the "Amount" header cell:

=SUM(A:A)-(COUNTA(A:A)-1)*$B$1



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Sum of a Range (with a twist)

Your formula is basically of the format:
(A-X) + (B-X) + (C-X) + ... + (n-X),
where n is the # rows and X = the value in B1

This is equivalent to:
A + B + C + ... + n - nX

So the cell formula is:
=SUM(A:A)-(COUNTA(A:A)-1)*B1

Take the sum of column A, subtract from it the product of the count of
non-blank cells in column A times the value in B1. Note the -1 in
COUNT(A:A)-1 is to account for the header cell "Amount".

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum of a Range (with a twist)


A simple formula:
=SUM(A1:A2)-COUNT(A1:A2)*(B1)

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=376699

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
Sum with a Twist Q Seanie Excel Worksheet Functions 2 December 30th 08 01:11 PM
If but with a twist:( AVB Over My Head New Users to Excel 3 September 16th 08 04:43 AM
Sum with a twist andrew Excel Discussion (Misc queries) 15 June 18th 08 08:56 AM
range, cell refrence, but with a new twist buzz Excel Worksheet Functions 5 July 11th 07 02:02 AM
Use VLookup for range of cells, but with a twist [email protected] Excel Worksheet Functions 1 April 24th 06 03:27 PM


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