# Count Colored Cells

#### jaybwise

##### New Member
I need to tell excel to count the colored cells ranging from D3 thru L123, then give me a percentage of the cells that are colored. any help is appreciated.

### Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
You can use VBA like this:
Code:
``````Public Sub ColorPercent()
Dim r As Range
Dim iCount As Integer
Dim sPercent As Single
iCount = 0
For Each r In Range("D3:L123")
If r.Interior.ColorIndex <> -4142 Then iCount = iCount + 1
Next r
sPercent = (iCount * 100 / Range("D3:L123").Count)
MsgBox sPercent
End Sub``````

Thanks for that, but I have no idea what that is. I only know basic stuff in excel.

1. Open Excel File where you need to implement this code.
2. Press ALT+F11 to open Visual Basic Editor Window.
3. Insert a module using Insert >> Module.
4. Select the code and Paste it in Blank Pane in the right side.

In Excel, open the sheet where you want to check percent. Then Press ALT+F8 to open Run Macro dialog. Select the macro "ColorPercent" and Run it.

Replies
5
Views
178
Replies
3
Views
169
Replies
42
Views
901
Replies
7
Views
319
Replies
6
Views
137

1,196,409
Messages
6,015,104
Members
441,870
Latest member
kojack

### 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.

### Which adblocker are you using?

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

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