How to Sum by Color in Excel? (2 Useful Methods)

The top two methods to Sum by Colors in Excel are as follows –

  • Usage of SUBTOTAL formula in excelSUBTOTAL Formula In ExcelThe SUBTOTAL excel function performs different arithmetic operations like average, product, sum, standard deviation, variance etc., on a defined range.read more and filter by color function.Applying GET.CELL formula by defining the name in the formula tab and applying the SUMIF formula in excelSUMIF Formula In ExcelThe SUMIF Excel function calculates the sum of a range of cells based on given criteria. The criteria can include dates, numbers, and text. For example, the formula “=SUMIF(B1:B5, “<=12”)” adds the values in the cell range B1:B5, which are less than or equal to 12.
  • read more to summarize the values by color codes.

Let us discuss each of them in detail –

#1 – Sum by Color using SUBTOTAL Function

To understand the approach for calculating the sum of values by background colors, let us consider the below data table, which provides details of amounts in US$ by region and month.

#2 – Sum by Color using Get.Cell Function

The second approach is explained to arrive at the sum of the color cells in excel, as discussed in the below example. Consider the data tableData TableA data table in excel is a type of what-if analysis tool that allows you to compare variables and see how they impact the result and overall data. It can be found under the data tab in the what-if analysis section.read more to understand the methodology better.

  • Suppose we would like to highlight those cells which are negative in values for indication purpose, this can be achieved by either applying conditional formatting or manually highlighting the cells, as shown below. To achieve the sum of cells that are colored in excel, enter the formula for SUBTOTAL below the data table. The syntax for the SUBTOTAL formula is shown below. The formula that is entered to calculate the summation is=SUBTOTAL(9,D2:D13)Here, the number 9 in the function_num argument refers to sum functionality, and the reference argument is given as the range of cells to be computed. Below is the screenshot for the same. As the above screenshot shows, a “USD Amount” summation has been calculated to compute the amounts highlighted in a light red background. Next, apply the filter to the data table by going to the “Data” tab and selecting a filter. Select filter by color and choose the light red cell color under “Filter by Color.” Below is the screenshot to better describe the filter. Once the excel filter has been applied,  it will filter the data table for only light red background cells. The subtotal formula used at the bottom of the data table would display the summation of the colored cells, which are filtered as shown below. As shown in the above screenshot, the computation of the colored cell is achieved in cell E17, subtotal formula.

The formula that is entered to calculate the summation is=SUBTOTAL(9,D2:D13)Here, the number 9 in the function_num argument refers to sum functionality, and the reference argument is given as the range of cells to be computed. Below is the screenshot for the same.

As shown in the above screenshot, the computation of the colored cell is achieved in cell E17, subtotal formula.

  • Step 1: Now, let us highlight the list of cells in the “USD Amount” column, which we are willing to arrive at the desired sum of colored cells, as shown below..

  • Step 2: As we can see in the above screenshot, unlike in the first example here, we have multiple colors. Thereby we will be using the formula =GET.CELL by defining it within the name boxName BoxIn Excel, the name box is located on the left side of the window and is used to give a name to a table or a cell. The name is usually the row character followed by the column number, such as cell A1.read more and not directly using it in excel.Step 3: Now, once the dialog box for the “Define Name” pops up, enter the name and the formula forgetting. CELL in “Refer to,” as shown in the below screenshot.

As seen in the above screenshot, the name entered for the function is “CellColor_Num,” and the formula =GET.CELL(38,’Example 2!$D2) is to be entered in ‘Refers to.’ Within the formula, the numeric 38 refers to the cell code information, and the second argument is the cell number D2 refers to the reference cell. Now, click “OK.”

  • Step 4: Now, enter the function name “CellColor” in the cell beside the color-coded cell, which was defined in the dialog box, as explained in step 3.

As seen in the above screenshot, the function “CellColor” is entered, which returns the color code for the background cell color.

Similarly, the formula is dragged for the entire column.

  • Step 5: Now, to arrive at the sum of the values by colors in excel, we will be entering the SUMIF formula. The syntax for the SUMIF formula is as follows:-

As can be seen from the above screenshot, the following arguments are entered into the SUMIF formula:-

  • The range argument is entered for cell range E2: E13.The criteria are entered as G2, whose summarized values are needed to be retrieved.The range of cells is entered to be D2: D13.

The SUMIF formula is dragged down for all the color code numbers for which values are to be added together.

Things to Remember

  • While using the approach by SUBTOTAL formula, this functionality allows the users to filter for only one color at a time. Moreover, we can utilize this functionality to add only one column of values by filtering colors if there is more than one column with different colors by rows in the various columns. The SUBTOTAL may only show the correct result for one filter by color to a specific column.The GET.CELL formula, combined with the SUMIF approach, eliminates this limitation, as we could use this functionality to summarize by colors for multiple color codes in the cell background.

This article is a guide to Sum by Color in Excel. Here, we discuss how to find sum by colors in Excel using 1) SUBTOTAL Function and 2) Get. Cell, along with practical examples and a downloadable Excel template. You may learn more about Excel from the following articles: –