Counting cells based on color using the immediate window?

JacobMortensen

Board Regular
Joined
Feb 25, 2015
Messages
85
Hi All.

Does one here know if it is possible to count the number of cells in a range that have a specific color?

I have tried this and it does not work:

Code:
?Application.worksheetfunction.countif(Range("A1:A10);interior.color = rgbred))
 

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
If your willing to use Vba:
Try this

This script will search Range ("A1:A20") to see if interior color is red.
You will get a message box telling you how many were found.
This script finds interior color not the result of Conditional Formatting that would require another type script.

Code:
Sub Count_Colored_Cells()
Dim c As Range
Dim ans As Long
ans = 0
    For Each c In Range("A1:A20")
    If c.Interior.Color = vbRed Then ans = ans + 1
    Next
    MsgBox "There are  " & ans & "  Cells colored red"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,004
Members
452,374
Latest member
keccles

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