Written by Allen Wyatt (last updated April 6, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365
Joseph has a worksheet that contains a list of values. Some of those values are above zero and others are below. He can use the SUM function to calculate a sum of the values, but he really wants to calculate a sum of the absolute value of each item in the list. So, the sum of the three values -33, 14, -5 would be 52 instead of -24.
There is no intrinsic function you can use to create the desired sum, but you can create a formula to perform the task. One method is to use the SUMIF function, in the following manner:
=SUMIF(A1:A10,">0")-SUMIF(A1:A10,"<0")
The first SUMIF sums all the values that are greater than zero, and the second sums all those less than zero. Thus, with the four values -33, 14, -5, 42, the first SUMIF would result in a sum of 56 (14 + 42) and the second would result in a sum of -38 (-33 + -5). When you subtract the second sum from the first (56 - -38) you get a final answer of 94, which is the sum of all the absolute values.
Another approach is to use the SUMPRODUCT function. The following formula will produce the desired result:
=SUMPRODUCT(ABS(A1:A10))
The function is typically used to multiply different elements of arrays by each other, and then sum those products. Since only one array (A1:A10) is provided, there is no multiplication done, but a sum of the desired absolute values is returned.
You can also get the desired result by using an array formula, a convenient but seldom used feature of Excel. Assuming your values are in the range A1:A10, type this formula:
=SUM(ABS(A1:A10))
If you are using a version of Excel prior to Excel 2021 or Excel in Microsoft 365, you'll need to enter this as an array formula. (In other words, press Ctrl+Shift+Enter to enter the formula.) The formula internally creates the intermediate column (which is an array of values) which are the individual absolute values of A1:A10. It then sums this array and displays the result.
Finally, if you prefer you could create your own user-defined function (a macro) that will return the sum of the absolute values in a range. The following will accomplish the task:
Function SumAbs(Rng As Range) As Double Dim c As Range Dim r As Double r = 0 On Error Resume Next For Each c In Rng r = r + Abs(c) Next c SumAbs = r End Function
You can use the function by entering a simple formula in your worksheet:
=SumAbs(A1:A10)
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12615) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Summing Absolute Values.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
When Excel performs a calculation, the results you see in an unformatted cell may cause a bit of concern. This tip ...
Discover MoreYou can use the Alt+Enter keyboard shortcut while entering information in order to force your data onto multiple lines in ...
Discover MoreIf you use serial numbers that include both letters and numbers, you might wonder how you can increment the numeric ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-04-07 12:12:24
Willy Vanhaelen
Here is a one-liner UDF that does the job:
Function SumAbs(Rng As Range)
SumAbs = Evaluate("SUM(ABS(" & Rng.Address & "))")
End Function
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments