FormulaCraft

How to sum cells by color in Excel and Google Sheets

Topic:SUM & aggregation
Excel & Google Sheets
=SUMIF(B2:B5,"Red",C2:C5)

Verified example

Computed by a real spreadsheet engine on the sample data below.

ItemColor LabelAmount
AppleRed100
BlueberryBlue200
StrawberryRed150
GrapeBlue180

=SUMIF(B2:B5,"Red",C2:C5)250

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Add a helper column (e.g. column B) and manually type the color label — "Red", "Blue", etc. — for each row to mirror the fill colors you applied.
  2. 2In an empty cell enter =SUMIF(B2:B5,"Red",C2:C5) to sum column C values where the helper column equals "Red".
  3. 3Alternatively in Excel, open the VBA editor (Alt+F11), create a function that reads Interior.Color and use it as =SumByColor("Red",C2:C5). In Google Sheets use Apps Script for the same purpose.

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

Is there a native SUMBYCOLOR function in Excel or Sheets?

No. Neither application exposes cell fill color to worksheet formulas natively. You must use a helper column, VBA, or Apps Script.

Will a VBA sum-by-color function work in Google Sheets?

No — VBA is Excel-only. Use Google Apps Script with getBackground() to build an equivalent custom function in Sheets.

More on SUM & aggregation

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: