Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Summing Absolute Values.

# Summing Absolute Values

by Allen Wyatt
(last updated June 2, 2018)

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))
```

Don't press Enter; instead press Ctrl+Shift+Enter, which signifies this is an array formula. If the formula is entered correctly, you'll see braces around the formula in the Formula bar:

```{=SUM(ABS(A1:A50))}
```

What the formula does is internally create 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 is a macro that will accomplish this task:

```Function SumAbs(Rng As Range) As Double
Result = 0
On Error GoTo Done
For Each element In Rng
Result = Result + Abs(element)
Next element
Done:
SumAbs = Result
End Function
```

You can use the function by entering a simple formula in your worksheet:

```=SumAbs(A1:A10)
```

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12615) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Summing Absolute Values.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Converting Text Into a Table

You can easily convert regular text into a table using a couple of different methods. This tip explains how to make the ...

Discover More

Creating a TOC that Includes Specific Styles

Want to create a special TOC that contains different elements of your document? It's easy to do if you consistently use ...

Discover More

Uppercase and Lowercase AutoCorrect Entries

AutoCorrect can be a great tool to correct, automatically, the typos and wording you enter in a document. Sometimes, ...

Discover More

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!

##### More ExcelTips (ribbon)

Developing Reciprocal Conversion Formulas

When converting between measurement systems, you might want to use two cells for each type of measurement. Make a change ...

Discover More

Indirectly Referencing a Cell on a Different Worksheet

Excel includes the powerful INDIRECT function which can be used to assemble references to other cells in your workbook. ...

Discover More

Using a Formula to Replace Spaces with Dashes

If you need a formula to change spaces to some other character, the SUBSTITUTE function fits the bill. Here's how to use it.

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five more than 5?

2020-03-08 09:55:57

Peter Atherton

Rannie
The most obvious way that a Value error is returned is if a number in the data is text. So I would examine the numbers carefully. The Following may help. If a number has been added with a leading apostrophe, then this number is treated as text. However, array formulas entered Ctrl + Alt + Enter and SUMPRODUCT functions will ignore this error. If a number has a space within it say 10 is entered 1 Space 0 then this produces a value error.

Use the Count Function if it does not give the correct number then a value(s) must be Text.

(see Figure 1 below)

Figure 1. Data Values

2020-03-07 13:49:03

Rannie R Dean

good afternoon,

I don't have time to read frequent emails.

I'm a real estate appraiser and do have the need for Excel help. I will be very glad to give you credit in any report I do for the contributions you have made.

I need the absolute sum of a column of numbers. I tried two of your suggestions multiple times each and could not get them to work.

I tried:

=SUMPRODUCT(ABS(D7:D19))

as well as

=SUM(ABS(D7:D19))

what did I do wrong?

2019-08-05 12:35:29

Willy Vanhaelen

The macro in this tip has a serious bug!

If the range contains a string (even a cell containing just a space) the UDF (User Defined Function) will produce a faulty result.
- An error will occur when the For Next loop encounters a cell containing a srtring.
- The "On Error GoTo Done" line causes the looping to stop and the line after 'Done:' will be executed.
- The result at that moment will be displayed skipping the rest of the range which is of course totally wrong.

So deleting the On Error line will fix this bug but here is a one-liner that does the same job correctly:

Function SumAbs(Rng As Range) As Double
SumAbs = Evaluate("SUM(ABS(" & Rng.Address & "))")
End Function

it shows #VALUE! in case your range contains a string just as the formulas do.
In fact it is simply the VBA implementation of the array formula {=SUM(ABS(Range))}

##### This Site

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.