sum range, but add a value to empty cells

danmillion

New Member
Joined
Mar 20, 2015
Messages
2
I have a range, say A1:A20. Some of the cells in this range are numbers, some are text (-,NA,MN, or even an error, such as #DIV/0!). I would like to create a sum of the existent number, but also add a specific number (say 99) to the cells that are text (or error, as mentioned previously)

A B <= columns
12 1
23 3
NA 1
blank NA
3 5
- 2
10 2
--------------------
345 113

=sum(12+23+99+99+3+99+10) = 345 => Rank = 1
=sum(1+3+1+99+5+2+2) = 113 => Rank= 2

The reason I am adding 99 is that I am ranking the sums/columns by the lowest sum (ascending). So higher sums, lower the rank.

Thanks for any help!!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Welcome to the board. Try:
Code:
=SUMPRODUCT(--(ISNUMBER(A1:A7)),A1:A7)+SUMPRODUCT(--(NOT(ISNUMBER(A1:A7))))*99
 
Upvote 0
Thanks for the response guys. Both solution work partially. Both formulas fails to recognize error, #DIV/0, to be more specific, but this I can prob handle it. Now, Mike, your solution is adding an extra 99 for empty cells or other text (NM, NA, -, etc). Also, if instead of 99 I used another number, the sum does not calculated correctly.
Jack, your formula works beautifully, including if I change 99 to another number! Awesome.
Quick question, can anybody explain what the "--" in front of the functions are for?

Again, thank you guys for taking the time to help me. I appreciate it.
 
Upvote 0
Upvote 0
Hi,

An alternative approach

=SUMIF(A1:A7,"<1E100")+(SUMPRODUCT(--(NOT(ISNUMBER(A1:A7))))*99)


You asked about the --. in the formula the SUMPRODUCT functions are returning TRUE or FALSE and sumproduct can't evaluate these so the -- coerces TRUE into 1 and FALSE into zero.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top