ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel - ignore red numbers when totaling rows (https://www.excelbanter.com/excel-programming/390156-excel-ignore-red-numbers-when-totaling-rows.html)

Chris Douglass

Excel - ignore red numbers when totaling rows
 
Excell 2002 SP3 - When totaling up my rows and columns I want Excel to ignore
any numbers I make red. ( I still want to see them - just not have them
included in the totals )

Thank you,

Chris

Chip Pearson

Excel - ignore red numbers when totaling rows
 
Chris,

You can do this only with code:

Function SumExceptColor(InputRange As Range, ExcludeCI As Integer, _
OfText As Boolean) As Double

Dim Rng As Range
Dim Total As Double
For Each Rng In InputRange.Cells
If IsNumeric(Rng.Value) = True Then
If OfText = True Then
If Rng.Font.ColorIndex < ExcludeCI Then
Total = Total + Rng.Value2
End If
Else
If Rng.Interior.ColorIndex < ExcludeCI Then
Total = Total + Rng.Value2
End If
End If
End If
Next Rng
SumExceptColor = Total

End Function

In this function, InputRange is the range to sum. ExcludeCI is the
ColorIndex to exclude from the summation (Red = 3), OfText indicates whether
to look at the color of text (if OfText = True) or the background (if OfText
= False) of each cell.

You can call this function with

=SumExceptColor(A1:A10,3,TRUE)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting LLC
www.cpearson.com
(email on the web site)




"Chris Douglass" <Chris wrote in message
...
Excell 2002 SP3 - When totaling up my rows and columns I want Excel to
ignore
any numbers I make red. ( I still want to see them - just not have them
included in the totals )

Thank you,

Chris





All times are GMT +1. The time now is 08:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com