FormatConditions Function for multiple conditional format

JoeBondro

New Member
Joined
Nov 27, 2014
Messages
2
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
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,219
Messages
6,123,684
Members
449,116
Latest member
HypnoFant

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