Reputation:
In excel, I have a column of numbers such that if the number is positive, the text color is black, if the number is negative, the number is red. How can I, in a fresh cell, total only the red numbers in the column?
Upvotes: 0
Views: 183
Reputation: 2502
Here is my example.
In this example I have a range of random integers between -100 and 100. This range is Sheet1!$B$3:$B$26
.
I have applied conditional formatting such that:
To do this, just highlight your range, set a conditional format using a custom formula, and set the format using the first cell in your range.
=B3>=0
. =B3<0
. I have created two cells which contain the sum of the table using the sumif() function:
=sumif(your_range, ">=0")
=sumif(your_range, "<0")
Note: that in your case, you said you want to sum the cells with red text, all of which are negative integers, so all I really need to do is sum the cells if they are a negative integer.
To truly sum cells based on a format such as text color, you could write a vba function/macro and iterate through the cells in the range.
Upvotes: 0