Hello,
I need help for using formatconditions(1) function for multiple conditional format in the cell range. I'm trying to get the sum of specific colors given by the conditional format. But when I use formatconditions(1) it sums all of the cells with different colors in the same color total. My conditional format works like this; the formula checks a data table and finds the color of the cell, and then it changes its color. There are 4 colors for all range of cells, so there 4 different conditional format for a cell.
this is my code:
Function CellColor(R As Range) As Long
CellColor = R.FormatConditions(1).Interior.ColorIndex
End Function
Function colorsum(CellColor As Range, rRange As Range)
Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.FormatConditions(1).Interior.ColorIndex
For Each cl In rRange
If cl.FormatConditions(1).Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next cl
colorsum = cSum
End Function
Thank you for your interest and help,
Joe
I need help for using formatconditions(1) function for multiple conditional format in the cell range. I'm trying to get the sum of specific colors given by the conditional format. But when I use formatconditions(1) it sums all of the cells with different colors in the same color total. My conditional format works like this; the formula checks a data table and finds the color of the cell, and then it changes its color. There are 4 colors for all range of cells, so there 4 different conditional format for a cell.
this is my code:
Function CellColor(R As Range) As Long
CellColor = R.FormatConditions(1).Interior.ColorIndex
End Function
Function colorsum(CellColor As Range, rRange As Range)
Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.FormatConditions(1).Interior.ColorIndex
For Each cl In rRange
If cl.FormatConditions(1).Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next cl
colorsum = cSum
End Function
Thank you for your interest and help,
Joe