Count no'of empty cells with no color fill

adiles

New Member
Joined
Jun 13, 2020
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am looking for a formula which will count the no of blank cells in a column having no color fill.
I have values in both filled and unfilled cells. i want to get the count of unfilled cells if there is no value in it.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I haven't touched Excel for a few years so this answer may not be up to date.
A few years back the only way to detect colour in a cell was by VBA. And you've stated you want a formula.
Unless things have changed that won't be possible.
 
Upvote 0
Hi all,

I am looking for a formula which will count the no of blank cells in a column having no color fill.
I have values in both filled and unfilled cells. i want to get the count of unfilled cells if there is no value in it.
Put this function into a standard code module and call it like this in a cell for example:

=fncCountCellsByColor(A1:A200)

where A1:A200 is the range that you are searching in.

If you want to search column A for example it will search from cell A1 to the last cell in the column containing a value.

e.g. =fncCountCellsByColor(A:A)

VBA Code:
Public Function fncCountCellsByColor(data_range As Range) As Long
Dim cellCurrent As Range
Dim cntRes As Long

  Application.Volatile
  
  cntRes = 0
  
  With data_range
  
    If .Columns.Count = 1 And (.Rows.Count = Cells.Rows.Count) Then
      
      Set data_range = Cells(1, data_range.Column).Resize(Cells(Rows.Count, 1).End(xlUp).Row, 1)
    
    End If
  
  End With
  
  For Each cellCurrent In data_range
    
    With cellCurrent.Interior
    
    If (.Pattern = xlNone) And _
        (.TintAndShade = 0) And _
        (.PatternTintAndShade = 0) Then
    
      cntRes = cntRes + 1
    
    End If
    
    End With
  
  Next cellCurrent

  fncCountCellsByColor = cntRes
 
End Function
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
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