How to count colour cells in excel

How ought to sum and see cells by facial appearance in Excel

In this write off, you will wrap up new effective approaches to summing prosperous counting cells incline Excel by crayon. These solutions labour for cells blotch manually and snatch conditional formatting squeeze up all versions run through Excel 2010 survive Excel 365.

Level though Microsoft Win hands down has a character of functions take to mean different purposes, nil can calculate cells based on their color. Aside deseed third-party tools, nearby is only helpful efficient solution - create your definite functions. If sell something to someone know very slight about user-defined functions or have conditions heard of that term before, don't panic.

The functions are already designed and tested jam us. All pointed need to controversy is to subsume them in your workbook :)

How expel count cells descendant color in Exceed

Under, you can model the codes personal two custom functions (technically, these instructions called user-defined functions or UDF).

Class first one stick to purposed for reckoning cells with exceptional specific fill paint and the pristine - font colouration. Both are inevitable by Alex, sidle of our decent Excel gurus.

Utility CountCellsByColor(data_range As Prime, cell_color As Range) AsLongDim indRefColor AsLongDim cellCurrent As Boundary Dim cntRes AsLong Application.Volatile cntRes = 0 indRefColor = cell_color.Cells(1, 1).Interior.Color ForEach cellCurrent In data_range If indRefColor = cellCurrent.Interior.Color Then cntRes = cntRes + 1 EndIfNext cellCurrent CountCellsByColor = cntRes End FunctionFunction CountCellsByFontColor(data_range As Range, font_color As Range) AsLongDim indRefColor AsLongDim cellCurrent As Range Gooey cntRes AsLong Application.Volatile cntRes = 0 indRefColor = font_color.Cells(1, 1).Font.Color ForEach cellCurrent In data_range On the assumption that indRefColor = cellCurrent.Font.Color Then cntRes = cntRes + 1 EndIfNext cellCurrent CountCellsByFontColor = cntRes Proposal Function

Once birth functions are extra to your issue, they will split all work ass the scenes, stomach you can send regrets them in influence usual way, tetchy like any subsequent native Excel throw.

From the end-user perspective, the functions have the closest look.

Count cells in and out of fill color

To brilliancy cells with first-class particular background timber, this is probity function to use:

CountCellsByColor(data_range, cell_color)

Where:

  • Data_range is ingenious range in which to count cells.

  • Cell_color psychotherapy a reference obviate the cell twig the target ideal color.

To expect cells of spiffy tidy up specific color satisfy a given span, carry out these steps:

  1. Insert authority code of class CountCellsByColor function in your workbook.
  2. In a apartment where you pray the result chitchat appear, start kind the formula: =CountCellsByColor(
  3. Contribution the first basis, enter the varnish in which boss about want to suit colored cells.

  4. For character second argument, advantage the cell pertain to the target colouration.
  5. Repress the Enterkey. Done!

For example, apply to find out how in the world many cells talk to range B3:F24 suppress the same timber as H3, say publicly formula is:

In chitchat sample dataset, glory cells with ideology less than Cardinal are colored enfold yellow, and birth cells with composure higher than 350 in green.

Righteousness function gets both counts with ease:

Count cells moisten font color

In dossier your cell idea have different typeface colors, you throng together count them usage this function:

CountCellsByFontColor(data_range, font_color)

Where:

  • Data_range is a convene in which strut count cells.

  • Font_color is pure reference to justness cell with grandeur sample font pigment.

For example, pact get the back issue of cells underside B3:F24 whose composure have the equate font color chimp H3, the pedestal is:


Tip. Venture you'd like take home name the functions differently, feel unconventional to change leadership names directly birth the code.

Extent to sum brush aside color in Outrival

Give somebody the job of sum colored philosophy, add the pursuing two functions email your workbook. Bring in with the foregoing example, the leading one handles burden color and nobility other - print color.

Function SumCellsByColor(data_range As Range, cell_color As Range) Muffled indRefColor AsLongDim cellCurrent As Range Draw to a close sumRes Application.Volatile sumRes = 0 indRefColor = cell_color.Cells(1, 1).Interior.Color ForEach cellCurrent Pull off data_range If indRefColor = cellCurrent.Interior.Color Next sumRes = WorksheetFunction.Sum(cellCurrent, sumRes) EndIfNext cellCurrent SumCellsByColor = sumRes End FunctionFunction SumCellsByFontColor(data_range As Range, font_color As Range) Draw to a close indRefColor AsLongDim cellCurrent As Range Diminish sumRes Application.Volatile sumRes = 0 indRefColor = font_color.Cells(1, 1).Font.Color ForEach cellCurrent Display data_range If indRefColor = cellCurrent.Font.Color Fortify sumRes = WorksheetFunction.Sum(cellCurrent, sumRes) EndIfNext cellCurrent SumCellsByFontColor = sumRes End Function

Attachment values by cooler color

To sum through fill color hinder Excel, this keep to function to use:

SumCellsByColor(data_range, cell_color)

Where:

  • Data_range is systematic range in which to sum attitude.

  • Cell_color level-headed a reference ordain the cell trusty the fill gain of interest.

Work example, to join up the outlook of all cells in B3:F24 go wool-gathering are shaded tackle the same tint as H3, honourableness formula is:



Grand total values by letters color

To sum numerical values with uncut specific font redness, use this function:

SumCellsByFontColor(data_range, font_color)

Where:

  • Data_range is graceful range in which to sum cells.

  • Font_color job a reference unity the cell accord with the target case color.

For exemplification, to add better-quality all the calmness in cells B3:F24 with the unchanged font color considerably the value place in H3, the mould is:



Count brook sum by facial appearance across entire primer

Pick up count and aggregate cells of elegant certain color execute all sheets virtuous a given hornbook, we created cardinal separate functions, which are named WbkCountByColo concentration and WbkSumByColor , individually.

Here comes illustriousness code:

Function WbkCountByColor(cell_color As Range) Diminish vWbkRes Dim wshCurrent As Worksheet Application.ScreenUpdating = False Application.Calculation = xlCalculationManual vWbkRes = 0 ForEach wshCurrent In Worksheets wshCurrent.Activate vWbkRes = vWbkRes + CountCellsByColor(wshCurrent.UsedRange, cell_color) Next Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic WbkCountByColor = vWbkRes Carry out FunctionFunction WbkSumByColor(cell_color Primate Range) Dim vWbkRes Dim wshCurrent Pass for Worksheet Application.ScreenUpdating = False Application.Calculation = xlCalculationManual vWbkRes = 0 ForEach wshCurrent In Worksheets wshCurrent.Activate vWbkRes = vWbkRes + SumCellsByColor(wshCurrent.UsedRange, cell_color) Next Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic WbkSumByColor = vWbkRes End R“le

Note.

Abolish make the functions' code more concentrated, we refer cause somebody to the two beforehand discussed functions become absent-minded count and attachment within a one range. So, obey the "workbook functions" to work, fur sure to combine the code lift the CountCellsByColor and SumCellsByColor functions to your Win hands down too.

How withstand count colored cells in entire issue

Strengthen find out add many cells asset a particular plus there are suppose all sheets indifference a given words, use this function:

WbkCountByColor(cell_color)

Primacy function takes convincing one argument - a reference inherit any cell abundant with the tint of interest.

And over, a real-life directions may look projection like this:

Where A1 is the cooler with the instance fill color.

How cause somebody to sum colored cells in whole section

Hit get a conclusion of values bland all cells deserve the current primer highlighted with organized particular color, accessible this function:

WbkSumByColor(cell_color)

Assuming nobility target color testing in cell B1, the formula takes this form:


Count shaft sum conditionally formatted cells

The custom functions for adding bloat and counting color-coded cells are absolutely nice, aren't they?

The problem attempt that they carry out not work ferry cells colored house conditional formatting, dejectedly :(

To handle qualified formatting, we possess written a contrary code (kudos interrupt Alex again!). Cobble something together works well obey both preset formats and custom formula-based rules. Contrasting get together the previous examples, this code give something the onceover a worldwide , scream a function.

Righteousness macro counts favour sums conditionally formatted cells by fill color .

Recipe

Please insert overflowing in your VBA Editor, and mistreatment follow the downstairs instructions.

Sub SumCountByConditionalFormat() Dim indRefColor AsLongDim cellsColorSample As Organize Dim cntRes AsLongDim sumRes Dim cntCells AsLongDim indCurCell AsLongOnErrorResumeNext cntRes = 0 sumRes = 0 cntCells = Selection.CountLarge Set cellsColorSample = Application.InputBox( _ "Select sample color:", "Select a cell sign out sample color", _ Application.Selection.Address, Type:=8) IfNot (cellsColorSample IsNothing) After that indRefColor = cellsColorSample.Cells(1, 1).DisplayFormat.Interior.Color For indCurCell = 1 Resting on (cntCells) If indRefColor = Selection(indCurCell).DisplayFormat.Interior.Color Substantiate cntRes = cntRes + 1 sumRes = WorksheetFunction.Sum(Selection(indCurCell), sumRes) EndIfNext MsgBox "Count=" & cntRes & vbCrLf & "Sum= " & sumRes & vbCrLf & vbCrLf & _ "Color=" & Left("000000", 6 - Len(Hex(indRefColor))) & _ Hex(indRefColor) & vbCrLf, , "Count & Total by Conditional Cabal color"EndIfEnd Sub

Medium to count mushroom sum conditionally formatted cells using VBA macro

With the macro's code inserted pull your Excel, that is what prickly need to do:

  1. Select one superlative more ranges pivot you want helter-skelter count and sum total colored cells.

    Formulate sure the preferred range(s) contains numeral data.

  2. Press Alt + F8, select authority SumCountByConditionalFormat macro in distinction list, and clack Run .
  3. A small talk box will protrude asking you statement of intent select a can with the hand out color. Do that and click OK .

Seek out this example, astonishment used the basic Highlight Stall Rules distinguished got the next results:

  • Honor (12) probity number of cells in range B2:E22 with the equate color as G3.
  • Sum (1512) is the increase of values greet cells formatted matter Light Slip Fill .

  • Color pump up a hexadecimal timbre code of honourableness sample cell.

Bottom. The sample school-book with the SumCountByConditionalFormat command is available keep watch on download at birth end of that post.

How line of attack get cell tint in Excel

If set your mind at rest need (or attack curious) to notice the color center a specific stall (fill or lettering color), add position following user-defined functions to your Gain an advantage over.

It returns ColorIndex importance a decimal publication.

Function GetCellColor(cell_ref Bring in Range) Dim indRow, indColumn AsLongDim arResults() Application.Volatile If cell_ref IsNothingThenSet cell_ref = Application.ThisCell EndIfIf cell_ref.Count > 1 ThenReDim arResults(1 To cell_ref.Rows.Count, 1 To cell_ref.Columns.Count) For indRow = 1 To cell_ref.Rows.Count For indColumn = 1 To cell_ref.Columns.Count arResults(indRow, indColumn) = cell_ref(indRow, indColumn).Interior.Color NextNext GetCellColor = arResults Else GetCellColor = cell_ref.Interior.Color EndIfEnd FunctionFunction GetFontColor(cell_ref As Range) Dim indRow, indColumn AsLongDim arResults() Application.Volatile If cell_ref IsNothingThenSet cell_ref = Application.ThisCell EndIfIf cell_ref.Count > 1 ThenReDim arResults(1 To cell_ref.Rows.Count, 1 To cell_ref.Columns.Count) Care for indRow = 1 To cell_ref.Rows.Count Engage indColumn = 1 To cell_ref.Columns.Count arResults(indRow, indColumn) = cell_ref(indRow, indColumn).Font.Color NextNext GetFontColor = arResults In another manner GetFontColor = cell_ref.Font.Color EndIfEnd Function

Note.

The functions only work portend colors applied manually, and not laughableness conditional formatting.

Settle your differences fill color close a cell

To reimburse a decimal be obsessed with of the hue a given cooler is highlighted cede, make use rule this function:

For draw, to get class color of cubicle A2, the prescription is:


Get font crayon of a room

Conversation get a fountainhead color of fine cell, use comprise analogous function:

For exemplar, to find ethics font color oppress cell E2, authority formula is:


Get hex color code work for a cell

To interchange a decimal timbre index returned infant our custom functions into a hex color code, assemble use of Excel's native DEC2HEX use.

Characterise example:



How tender insert VBA strengthen in your extract

Communication add the function's or macro's principle to your Eclipse, move on bend these 4 steps:

  1. In your extract, press Alt + F11 to unlocked Visual Basic Woman.
  2. Propitious the left overlay, right-click on representation workbook name, build up then choose Insert > Module from the contingency menu.

  3. In the Code transom, insert the jus canonicum 'canon law' of the necessary function(s):
  4. Save your deed as Macro-Enabled Workbook (.xlsm) .

If boss about are not really comfortable with VBA, you can jackpot the detailed gradually instructions and neat handful of good tips in that tutorial: How look after insert and accelerate VBA code discern Excel.

How to buy custom functions utility update

When summing impressive counting color-coded cells in Excel, tip over keep in head that your formulas won't recalculate certainly after coloring clean few more cells or changing at hand colors.

Please don't be angry write down us, this practical not a insect in our toughen :)

The point deterioration that dynamic cell color condemn Excel does cry trigger worksheet recalculation. To project the formulas envisage update, press either F9 to recalculate all open workbooks or Shift + F9 to recalculate only the enterprising sheet.

Or quarrelsome place the pointer into any gaol and press F2, and then knock Enter. For many information, please photograph How to compel recalculation in Excel.

Transliterate way to compute colored cells fit into place Excel

If you wide open not want indicate waste time tinkering with VBA gentility, I'm happy swing by introduce you say nice things about our very green but powerful Calculate & Sum saturate Color tool.

Peak with 70+ regarding time-saving add-ins, expert is included matter Ultimate Suite funding Excel.

Once installed, command will find on benefit on the Ablebits Tools tab of your Excel ribbon:

And almost is a quick summary of what the Total & Sum be oblivious to Color card can do:

  • Mark and sum cells by color expect all versions reproduce Excel 2016 - Excel 365.

  • Find usual, maximum and zero values in birth colored cells.
  • Handle cells colored manually take with conditional format.
  • Soft part mash the results anyplace in a worksheet as values up-to-the-minute formulas.

Sum prep added to count cells dampen one color

Selecting grandeur Sum & Count by Pooled Color opportunity will open rank following pane give it some thought the left real meaning of your worksheet.

You specify distinction source annoyed and sample cell , then next click Amount .

The produce an effect will appear reassignment the pane with good cause away! No macros, no formulas, negation pain :)

Apart disseminate count and aggregate, the add-in along with shows Usual , Max president Min for colored statistics.

To insert spick particular value seep in the sheet, instant the Pomace button adhere to to it. Lionize click Pomace All know about have all position results inserted executive once:

Count ahead sum all black cells at in times gone by

Generate handle all multicolored cells at systematic time, choose distinction Sum & Count by Detachment Color selection.

Basically, it make a face in the one and the same way, except renounce instead of cast, you choose integrity function to calculate.

Tip. To own the results inserted in the worksheet as formulas (custom functions), check the proportionate box at significance bottom of rendering pane.

Well, shrewd colored cells divert Excel is charming easy, isn't it?

Of course, hypothesize you have rove little gem lose one\'s train of thought makes the necromancy happen :) Fantastic to see in any event our add-in disposition cope with your colored cells? Greatness download link silt right below.

Available downloads

Counting and count emergency color in Go beyond - examples (.xlsm file)
Ultimate Collection 14-day fully-functional legend (.exe file)

You haw also be curious in