How to count coloured cells and then work out a percentage.

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I would like to work out a percentage of the completed checks on a daily basis. Updates when I open the file.

I have red, blue, green and yellow cells in col B and if the checks have been completed then the operator signs them off in col H.

I already have a code that finds today's date and then depending on the time it then finds the correct shift, which then becomes the active row.

What I am thinking is a code or formula to count the coloured cells (col B) individually that are above the active row and then count the the coloured cells that have been signed off (col H).

Then work out the percentage of checks that have been completed.

I hope this makes sense and any help would be appreciated.

Thanks

Dan
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
As far as I know formulas cannot detect the colour of a cell unless that cell's colour has been set by Conditional Formatting, in which case just use the same conditions.
So it would most likely need to be done via VBA.

UPDATE: This may work...
 
Upvote 0
Hi,

Thank you for your suggestion and you're right, it seems to be a bit of both and I've been searching online and I have found this:

VBA Code:
Function Color_Cell_Count(ColorCell As range, DataRange As range)
Dim Data_Range As range
Dim Cell_Color As Long
Cell_Color = ColorCell.Interior.ColorIndex
For Each Data_Range In DataRange
If Data_Range.Interior.ColorIndex = Cell_Color Then
Color_Cell_Count = Color_Cell_Count + 1
End If
Next Data_Range
End Function

and then my formula is:
=Color_Cell_Count(L1,$B$5:$B$736).

It works well but I still want to run it from the activecell. So I was wondering if I can swap the range B5:B736 with the following macro?

VBA Code:
Sub aaaa()
range(ActiveCell, ActiveCell.End(xlUp)).Select
End Sub

any help would be appreciated.

Thanks Dan
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,184
Members
448,949
Latest member
keycalinc

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