How to Find Sum If Cell Color Is Green in Excel (4 Easy Methods)

If you want to find out the sum If the cell color is green in Excel, then you have come to the right place. Here, we will walk you through 4 easy methods to do the task smoothly.
Here, you can see in the following picture that we have found out the Sum of the Green Colored Sales in cell D12. In the following article. we will describe how you can also do the task.

Sum When Cell Color Is Green in Excel


4 Easy Methods to Find Sum in Excel If Cell Color Is Green

In the following dataset, you can see the Month and Sales columns. Here, you can easily notice that the Sales column has several cells colored in Green. Next, using this dataset we will find the sum if the cell color is green. Here, we used Excel 365. You can use any available Excel version.

Sample Excel Dataset with Some Green Colored Cells


1. Apply SUMIF Function Using a Helper Column with Color Names Written Manually

In this method, we will use the SUMIF function to find out the sum if the cell color is green. Here, we have added a Color column to our dataset. Next, we will use the SUMIF function to find out the sum of the Green color Sales.

Adding a helper column for color names

Steps:

  • First of all, we will type the following formula in cell C12.
=SUMIF(D5:D11,"Green",C5:C11)

 Using SUMIF Function for Excel if cell color is green then sum

Formula Breakdown:

  • SUMIF(D5:D11, “Green”, C5:C11) → the SUMIF function finds the sum of a range of cells based on specified criteria.
  • D5:D11 → is the range.
  • Green → is the criteria.
  • C5:C11 → is the sum_range.

Output: $4600

  • After that, press ENTER.
  • Therefore, you can see the result in cell C12.

Result after using SUMIF Function for Excel if cell color is green then sum

Read More: How to Use If Statement Based on Cell Color in Excel


2. Use SUBTOTAL Function and Then Apply Filter Command to Filter Out Green Cells

In this method, we will use the SUBTOTAL function to find out the total Sales sum. Then, we will use the Filter feature to find the sum if the cell color is green.

Steps:

  • In the first place, we will type the following formula in cell C12.
=SUBTOTAL(9,C5:C11)

 Applying the SUBTOTAL function to sum if cell color is green

Formula Breakdown:

  • SUBTOTAL(9, C5:C11) → the SUBTOTAL function finds out the subtotal in a range of cells.
  • 9 → indicates the function_num.
  • C5:C11 → is ref_1.

Output: $4600

  • After that, press ENTER.
  • Therefore, you can see the result in cell C12.

The output of SUBTOTAL Function

  • Afterward, to add the Filter icon to the column headings, we will select the column headings bu selecting cells B4:C4.
  • After that, go to the Data tab >> select Filter.

Use of Filter feature

  • As a result, you can see the Filter icon in the column headings.

Added Filter con to Column Headings

  • Moreover, we will click on the Filter icon of the Sales >> select Filter by Color.
  • After that, click on the green color.

Here, you can insert a Table and use the Filter by Color to filter the Green color and find the sum of these green-colored cells.

Use of Filter by Color Command for Excel if cell color is green then sum

  • As a result, you can see the Sum of the Green Colored Sales in cell D12.

The result after using the Filter feature

Read More: How to Use Conditional Formatting If Statement Is Another Cell


3. Use GET.CELL Function to Get Color Code for Green and Then Sum Using SUMIF Function

In this method, we will use the GET.CELL function from Name Manager to find the sum if the cell color is green.

Steps:

  • First of all, we will go to the Formulas tab >> select Name Manager.

Selecting Name Manager for Excel if cell color is green then sum

  • After that, a Name Manager dialog box will appear.
  • Then, click on New.

Selecting New in the Name Manager dialog Box

  • After that, a New Name dialog box will appear.
  • Then, in the Name box, we will type color_code.
  • In addition, in the Refers to box, we will type the following formula.

=GET.CELL(38, Sheet2!$C5)

Typing Formula in the New Name dialog box

  • Afterward, click on Close.

Selecting Close in the Name Manager dialog box

  • Furthermore, we will type the following formula in cell D5.
=color_code

 Use of color_code function

  • In addition press ENTER.
  • As a result, you can see the result in cell D5.
  • Furthermore, we will drag down the formula with the Fill Handle tool.

Applying the Fill Handle tool

  • Hence, you can see the complete Color Code column.

Complete Color Code

  • Next, we will type the following formula in cell D12.
=SUMIF(D5:D11,4,C5:C11)
  • Afterward, press ENTER.
  • Therefore, you can see the result in cell D12.

Result after using SUMIF Function for Excel if cell color is green then sum

Read More: SUMIF vs SUMIFS in Excel 


4. Apply VBA Codes to Sum Green Cells Only

In this method, we will use VBA code to find the sum if the cell color is green in Excel. We will go through two ways to do tasks.

4.1. Get Color Code with VBA and Then Apply SUMIF Function to Get the Sum

Here, we will use the VBA function to find the sum if the cell color is green.

Steps:

  • In the first place, go to the Developer tab >> select Visual Basic.
  • This will bring out a VBA Editor window.
  • Here, you can also press ALT+F11 to bring out the VBA Editor window.

Using Developer tab for Excel if cell color is green then sum

  • At this point, a VBA Editor window will appear.
  • Then, from the Insert tab >> select Module.

Inserting Module

  • Furthermore, we will type the following code in the Module.
Function index_for_color(CellColor As Range)
   index_for_color = CellColor.Interior.ColorIndex
End Function

VBA Code in the Module

  • Next, Save the code >> go back to the Worksheet.
  • Then, we will type the following formula in cell D5.
=index_for_color(C5)

Typing VBA function in cell D5.

  • Furthermore, press ENTER.
  • After that, you can see the index of the color Green in cell D5.
  • Moreover, we will drag down the formula with the Fill Handle tool.

Dragging Formula Using Fill Handle Tool

  • Hence, you can see the complete Index for Color column.

Complete Index for Color column

  • Afterward, to find the Sum of the Green Colored Sales, we will type the following formula in cell D12.

=SUMIF(D5:D11,4, C5:C11)

Applying SUMIF Function

  • In addition, press ENTER.
  • Hence, you can see the result in cell D12.

Result after using SUMIF Function

Read More: How to Use 3D SUMIF for Multiple Worksheets in Excel


4.2. Create a VBA Function to Get Added Value for a Selected Color (Green)

Here, we will use the VBA code to get the summed-up value if the cell color is green in Excel.

Steps:

  • First, we followed the steps of 5.1 to bring the Module.
  • After that, we type the following code in the Module.
Function Sum_by_Green_Color(Cell_Color As Range, rRange As Range)
Dim c_sum As Double
Dim col_index As Integer
col_index = Cell_Color.Interior.ColorIndex
For Each cl In rRange
   If cl.Interior.ColorIndex = col_index Then
   c_sum = WorksheetFunction.Sum(cl, c_sum)
   End If
Next cl
Sum_by_Green_Color = c_sum
End Function

VBA Code to Get Summed up Value

  • After that, we will go back to our Worksheet.
  • Next, we will type the following formula in cell C13.
=Sum_by_Green_Color(C5,C5:C11)

Applying Sum_by_Green_Color Function

  • After that, press ENTER.
  • Therefore, you can see the result in cell C13.

Result after using VBA for Excel if cell color is green then sum

Read More: How to Sum Colored Cells in Excel 


Practice Section

You can download the Excel file and practice the explained methods.

Practice Section for Excel if cell color is green then sum


Download Practice Workbook

You can download the Excel file from the following link and practice while reading this article.


Conclusion

Here, we show you 4 easy methods for Excel if the cell color is green then sum. Thank you for reading this article. We hope it was helpful. If you have any queries, please let us know in the comment section.


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Afia Kona
Afia Kona

Afia Aziz Kona, a graduate of Civil Engineering from Khulna University of Engineering & Technology, Bangladesh, serves as a technical content creator in the ExcelDemy project. Possessing a passion for innovation and critical thinking, she actively embraces challenges. Beyond her engineering background, Afia exhibits a keen interest in Excel, having authored numerous articles on Excel & VBA-related issues to simplify the experience for users facing obstacles in Excel. Apart from creating Excel tutorials, she is also... Read Full Bio

2 Comments
  1. Thanks for the tutorial, now how do I sum the cells if the cell color is green, blue, and red?

    • Hello ZHENG,
      Thank you for taking the time to read our article. If you have cells of different colors (such as green, blue, and red) and want to sum them up, the easiest way is to use the SUBTOTAL function with the Filter command. For example, let’s say you have sales values in the range C5:C11, where cells C5, C7, and C10 are green, C6 and C8 are blue, and C9 and C11 are red. Illustrating Colored Cells
      1. To get the sum of a definite colored cell, insert the formula in a cell:=SUBTOTAL(9,C5:C11)
      Here, the SUBTOTAL function inserted in cell C12 uses 9 as the “function_name” argument (which refers to the SUM function) and C5:C11 as “ref1”. Inserting SUBTOTAL Formula
      2. Select the column header and go to the Data tab > Sort & Filter > Filter. Selecting Filter Command
      3. Click on the Filter icon of the column and select “Filter by Color.” You will see three different colors to choose from.
      4. Select the color you want to sum up, and you will get the sum of all the cells with that color. Choosing a color to filter by color
      You can see the blue-colored cells filtered and summed up.
      Cells Summed and Filtered by Color

      We hope this helps! Let us know if you have any further questions.

      Regards,
      Exceldemy Team

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo