Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Calculate by Cell Background Color in Excel

Explore Calculate by Cell Background Color in Excel with a clear summary of the key facts, context, and practical details readers should know.

Table of Contents

This article provides a clear overview of Calculate by Cell Background Color in Excel, with the main facts, useful context, and practical details organized for easy reading.

Example

The colors have corresponding values. Sum the values corresponding to the cell's background color.

Calculate by Cell Background Color in Excel — Example screenshot 1

Step 1: Press the key combination Alt + F11 to open VBA 's working window -> Go to Insert tab -> Module .

Calculate by Cell Background Color in Excel — Example screenshot 2

Step 2: Build the function to calculate the total by color (named SumByColor ). Enter the following code into the newly created Module:

Calculate by Cell Background Color in Excel — Example screenshot 3

Function SumByColor (cellColor As Range, rRange As Range) Dim tong As Long Dim mau_sac As Integer mau_sac = cellColor.Interior.ColorIndex For Each c In rRange If c.Interior.ColorIndex = mau_sac Then tong = WorksheetFunction.Sum (c, tong) End If Next c SumByColor = tong End Function 

Note: Remember the name of the function you just created.

Step 3: Go back to the Excel File to calculate and select the SumByColor function as shown below:

Calculate by Cell Background Color in Excel — Example screenshot 4

Step 4: The SumByColor function (cellColor, rRange) has 2 arguments that are the color value of the cell and the data range to be calculated -> Enter the statement as shown:

Calculate by Cell Background Color in Excel — Example screenshot 5

Step 5: Convert the cell address to absolute address, highlight the address area and press F4. (You should do this step to avoid errors).

Calculate by Cell Background Color in Excel — Example screenshot 6

Finally Copy the formula to the remaining cells -> Result:

Calculate by Cell Background Color in Excel — Example screenshot 7

FAQ

What is the main focus of Calculate by Cell Background Color in Excel?

The article explains the most important facts, context, and practical details related to Calculate by Cell Background Color in Excel.

Who may find this information useful?

It is useful for readers who want a clear overview, practical context, and a better understanding of the subject.

What should readers verify before taking action?

Check current product versions, official requirements, regional availability, and any details that may have changed since the original publication.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.