Coloured Cells/Contents

MarcosM

New Member
Joined
Aug 27, 2019
Messages
9
Hi Guys, bit a headscratcher, I have a roster that im trying to calculate.

The roster has several employees, each with there own colour and how many hours they have, eg, A1, A2 and A3 are Green and have 1 in each cell.

So lets say Alan, who is "green" will have a total of 3.

Is there a function to capture this automatically...?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi & welcome to MrExcel.
How are the cells getting coloured?
 
Upvote 0
Maybe this...
Copy this into a standard module

Code:
Function CCI(rng As Range, iColor As Integer)
Dim rCell As Range, isum As Integer
isum = 0
For Each rCell In rng
    If rCell.Interior.ColorIndex = iColor Then
        isum = isum + rCell.Value
    End If
Next rCell
CCI = isum
End Function

Then highlight the range to sum and use the formula

Code:
=CCI(A1:F1000,3)

A1:F1000 being your cell range AND 3 ( currently red) for the colour code of your cells
 
Last edited:
Upvote 0
Maybe this...
Copy this into a standard module

Code:
Function CCI(rng As Range, iColor As Integer)
Dim rCell As Range, isum As Integer
isum = 0
For Each rCell In rng
    If rCell.Interior.ColorIndex = iColor Then
        isum = isum + rCell.Value
    End If
Next rCell
CCI = isum
End Function

Then highlight the range to sum and use the formula

Code:
=CCI(A1:F1000,3)

A1:F1000 being your cell range AND 3 ( currently red) for the colour code of your cells

Thanks for the reply, I found the following and it worked a treat :laugh::

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]https://www.ablebits.com/office-addins-blog/2013/12/12/count-sum-by-color-excel/comment-page-2/[/FONT]
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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