ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sum all Cells with Interior Color Index not equal to 0 (https://www.excelbanter.com/excel-programming/411372-sum-all-cells-interior-color-index-not-equal-0-a.html)

RyanH

Sum all Cells with Interior Color Index not equal to 0
 
I need to sum cells in Range("F5:F" & LastRow) that have a Interior Color
Index < 0. Is there an easy way to do this?

Thanks is Advance,
Ryan

JE McGimpsey

Sum all Cells with Interior Color Index not equal to 0
 
One way:

First, 0 is not a valid value for Range.Interior.ColorIndex. I assume
you mean xlColorIndexNone instead.

For Each rCell In Range("F5:F" & LastRow)
With rCell
If IsNumeric(.Value) Then _
If .Interior.ColorIndex < xlColorIndexNone Then _
dResult = dResult + .Value
End With
Next rCell

In article ,
RyanH wrote:

I need to sum cells in Range("F5:F" & LastRow) that have a Interior Color
Index < 0. Is there an easy way to do this?

Thanks is Advance,
Ryan


RyanH

Sum all Cells with Interior Color Index not equal to 0
 
I should have thought of that, thanks for the help!

Ryan

"JE McGimpsey" wrote:

One way:

First, 0 is not a valid value for Range.Interior.ColorIndex. I assume
you mean xlColorIndexNone instead.

For Each rCell In Range("F5:F" & LastRow)
With rCell
If IsNumeric(.Value) Then _
If .Interior.ColorIndex < xlColorIndexNone Then _
dResult = dResult + .Value
End With
Next rCell

In article ,
RyanH wrote:

I need to sum cells in Range("F5:F" & LastRow) that have a Interior Color
Index < 0. Is there an easy way to do this?

Thanks is Advance,
Ryan




All times are GMT +1. The time now is 02:45 AM.

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