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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
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,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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