Counting coloured cells that are blank

smilinglilies

New Member
Joined
Jan 25, 2019
Messages
9
Hi

I have a spreadsheet that has different colours in. I need to be able to count all blank orange cells within a certain range.

Countblank doesn't work, so I thought of perhaps using countccolor as I can get it to count all the orange cells but then I don't know what to add to it to count just blank cells.

Could someone point me in the right direction please

Thank you
 

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.
Can you supply the code you have for countcolor
 
Upvote 0
Function CountCcolor(range_data As Range, criteria As Range) As Long
Dim datax As Range
Dim xcolor As Long
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
If datax.Interior.ColorIndex = xcolor Then
CountCcolor = CountCcolor + 1
End If
Next datax
End Function



Using the formula =countccolor(E14:AI17,G2) gives me 23 which is correct, I now need to know how many of these 23 orange cells have no data in them.
 
Last edited:
Upvote 0
OK, try
Code:
Function CountCcolor(range_data As Range, criteria As Range) As Long
Dim datax As Range
Dim xcolor As Long
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
   If datax.Interior.ColorIndex = xcolor And datax.Value = "" Then
      CountCcolor = CountCcolor + 1
   End If
Next datax
End Function
 
Upvote 0
Thank you - would I be able to use the old formula on the same spreadsheet at the same time as I use it to work out the availability overall - the new formula is to break it down into 2 and 3 bed villas and what is still available.
 
Upvote 0
You can use
Code:
Function CountCcolor(range_data As Range, criteria As Range, Optional ValU As String = "*") As Long
Dim datax As Range
Dim xcolor As Long
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
   If datax.Interior.ColorIndex = xcolor And datax.Value Like ValU Then
      CountCcolor = CountCcolor + 1
   End If
Next datax
End Function
Then this
=countccolor(E14:AI17,G2)
will count all, or this
=countccolor(E14:AI17,G2,"")
will count blanks
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

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