Count coloured cells in a range which has been conditionally formatted

Sallyprit

New Member
Joined
Jan 25, 2024
Messages
13
Office Version
  1. 365
Platform
  1. Windows
1706622226276.png

I have created conditional fomatting with the condition =AND(I2-TODAY()<=90,I2-TODAY()>$P$990). This works well and formats the cells correctly with expiry dates of between today and 90 days time. I now need to count the umber of cells of that colour in each column & have created a function:

Function GetColorCount(CountRange As Range, CountColor As Range)

Dim CountColorValue As Integer

Dim TotalCount As Integer

CountColorValue = CountColor.Interior.ColorIndex

Set rCell = CountRange

For Each rCell In CountRange

If rCell.Interior.ColorIndex = CountColorValue Then

TotalCount = TotalCount + 1

End If

Next rCell

GetColorCount = TotalCount

End Function


Cell F3 uses this function to count the coloured cells. It will not count conditionally formatted cells but I can format a cell manually with the sdame orange & it counts it. Help please!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
What are the conditional formatting rules for changing cell colors? You can use the same rules in a formula.
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,976
Members
449,095
Latest member
Mr Hughes

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