Cindy has a fully formatted worksheet that uses color in many cells. Some of the cells have values in them; many do not. She needs a way to count any colored cells that are empty and wonders if there is a quick way to do this.
There are a few ways you can get the information you need. One way is to go through these steps:

Figure 1. The Go To Special dialog box.

Figure 2. The Find tab of the Find and Replace dialog box.

Figure 3. The Fill tab of the Find Format dialog box.
When you perform these steps, Excel shows, at the bottom of the Find and Replace dialog box, how many cells it found that match your color. Since you started the search with only blank cells selected, the resulting count is all those cells that are blank that are filled with the color.
Of course, if you need to determine this count quite a few times, then these steps can get very tedious very quickly. In such cases it is a better idea to use a macro. The following macro steps through each blank cell in whatever range you have selected and checks to see if it contains a pattern or a color and is empty. If the conditions are fulfilled, then a counter for that color is incremented.
Sub CountBlankColors1()
Dim c As Range
Dim J As Integer
Dim ColorCount(56) As Long
ActiveSheet.Range("a1").CurrentRegion.SpecialCells(xlCellTypeBlanks).Select
For Each c In Selection
With c.Interior
If .Pattern <> xlNone Then
If .ColorIndex <> xlNone Then
If IsEmpty(c) Then
ColorCount(.ColorIndex) = _
ColorCount(.ColorIndex) + 1
End If
End If
End If
End With
Next c
sTemp = "These are the color counts" & vbCrLf & vbCrLf
For J = 0 To 56
If ColorCount(J) > 0 Then
sTemp = sTemp & "Color " & J & ": " & ColorCount(J) & vbCrLf
End If
Next J
MsgBox sTemp
End Sub
Of course, you might not want to count different colors individually. Instead, you might want to know simply how many blank cells are filled with any color, in aggregate. In that case the macro becomes much simpler.
Sub CountBlankColors2()
Dim c As Range
Dim x As Long
x = 0
ActiveSheet.Range("a1").CurrentRegion.SpecialCells(xlCellTypeBlanks).Select
For Each c In Selection
If c.Interior.Pattern <> xlNone Then
If c.Interior.ColorIndex <> xlNone Then
If IsEmpty(c) Then x = x + 1
End If
End If
Next c
MsgBox "Number of colored blank cells: " & x
End Sub
It should be noted that these approaches don't take into consideration if the cell is colored through the use of a conditional format or not. (In fact, they don't take conditional formats into account at all.)
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12581) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2019 For Dummies today!
When creating a workbook to be used by others, you may want any worksheets they add to the workbook to contain some ...
Discover MoreOne of the things you can do with macros is to work with disk files. As you do so, you may have a need to create a new ...
Discover MoreIf you need to limit the cells that are accessible by the user of a worksheet, VBA can come to the rescue. This doesn't ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-05-29 16:21:20
J. Woolley
The Tip says its macros "don't take conditional formats into account at all." My comment dated 2024-05-27 included two macros named CountEmptyColored and CountBlankColored. To account for conditional formats as well as fill formats in each of those macros, simply replace the following statementn With c.Interiornwith this statementn With c.DisplayFormat.InteriornSimilar changes could be made to the Tip's macros.
2024-05-28 15:30:57
J. Woolley
Re. the first two paragraphs of my most recent comment below:n"Define an empty cell as one with no content and a blank cell as one that appears empty but might have content. A blank cell might be empty or it might contain a single apostrophe (') or a space character or a formula that returns null text (""), etc.n"The Range.SpecialCells(xlCellTypeBlanks) method returns empty cells only; blank cells are not included despite the name."nWhen c is a Range object representing a single cell, VBA's IsEmpty(c) function returns True for an empty cell and False for a blank cell that is not empty. Therefore, the Tip's use of IsEmpty(c) in its macros is superfluous.nExcel's ISBLANK function returns TRUE for an empty cell and FALSE for a blank cell that is not empty; therefore, it should be named ISEMPTY. nNotice Excel's WorksheetFunction object does not include an IsBlank method because that would duplicate VBA's IsEmpty function.nUsing the above definitions of blank and empty, My Excel Toolbox includes the following two functions:n =IsCellBlank(Target)n =IsCellEmpty(Target)nIsCellBlank returns TRUE if Target is blank, FALSE if not.nIsCellEmpty returns TRUE if Target is empty, FALSE if not. nIf Target is a contiguous range with more than one cell, an array is returned with TRUE/FALSE corresponding to each cell in Target.nSee https://sites.google.com/view/MyExcelToolbox/
2024-05-27 11:22:04
J. Woolley
Define an empty cell as one with no content and a blank cell as one that appears empty but might have content. A blank cell might be empty or it might contain a single apostrophe (') or a space character or a formula that returns null text (""), etc.nThe Range.SpecialCells(xlCellTypeBlanks) method returns empty cells only; blank cells are not included despite the name. nHere's a version of the Tip's CountBlankColors2 that counts empty colored cells as requested by Cindy.nnSub CountEmptyColored()n Dim c As Range, x As Longn x = 0n On Error GoTo Donen ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks).Selectn On Error GoTo 0n For Each c In Selectionn With c.Interiorn If .Pattern = xlSolid Thenn If .ColorIndex <> xlAutomatic Then x = x + 1n ElseIf .Pattern <> xlNone Thenn x = x + 1n End Ifn End Withn Next cnDone: MsgBox "Number of empty colored cells: " & xnEnd SubnnHere's a version that counts blank colored cells, which Cindy might prefer.nnSub CountBlankColored()n Dim c As Range, x As Longn x = 0n ActiveSheet.UsedRange.Selectn For Each c In Selectionn If Trim(c.Value) = "" Thenn With c.Interiorn If .Pattern = xlSolid Thenn If .ColorIndex <> xlAutomatic Then x = x + 1n ElseIf .Pattern <> xlNone Thenn x = x + 1n End Ifn End Withn End Ifn Next cn MsgBox "Number of blank colored cells: " & xnEnd SubnnNotice UsedRange includes cells with a fill color or pattern. A cell with a pattern will have a color and vice versa. But if the pattern is solid and the color is automatic, the cell will have the normal background color and appear to have no color; such cells are not counted in these macro versions but are counted by the Tip's macros. Finally, xlPatternNone and xlColorIndexNone are the same as xlNone, xlPatternSolid is the same as xlSolid, and xlColorIndexAutomatic is the same as xlAutomatic.
2024-05-25 14:40:47
J. Woolley
Re. my previous comment below, SpecialCells(...) is a method, not a property.
2024-05-25 14:37:55
J. Woolley
The following statement should be added to the Tip's CountBlankColors1 macron Dim sTemp As StringnIn both macros, the following statementnActiveSheet.Range("a1").CurrentRegion.SpecialCells(xlCellTypeBlanks).Selectnprobably should be replaced by this statementn ActiveSheet.Range("a1").SpecialCells(xlCellTypeBlanks).Selectnbut the result might be the same. nNotice when cells in the range A1:B2 are blank (empty), the following statementn ActiveSheet.Range("a1").CurrentRegion.Selectnselects only cell A1 even if cells beyond A1:B2 are not blank. The property SpecialCells(...) apparently extends this selection beyond CurrentRegion to UsedRange.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2026 Sharon Parq Associates, Inc.
Comments