Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in


How to sum cells when value changes in another column?

doc sum when value changes 1

When you work on Excel worksheet, sometime, you may need to sum cells based on group of data in another column. For example, here, I want to sum the orders in column B when the data changes in column A to get the following result. How could you solve this promblem in Excel?

Sum cells when value changes in another column with formula

Sum cells when value changes in another column with Kutools for Excel

arrow blue right bubble Sum cells when value changes in another column with formula

Here is a simple formula which can help you to solve this task, please do as follows:

Enter this formula: =IF(A3<>A2,SUM($B$2:B2)-SUM($C$1:C1),"") into a blank cell beside your data range that you want to sum, C2, for example, and then drag this formula down to the cells that you want to get the results, and the cells in column B have been added together based on the value changes in column A. See screenshot:

Note: In the above formula, A3, A2 are the first two cells in the column which is used to identify the cell changes, B2 is the first cell in the number column that you want to sum, C1 is the cell above your formula. You can change them to your need.

doc sum when value changes 2

arrow blue right bubble Sum cells when value changes in another column with Kutools for Excel

If you have Kutools for Excel, with its Advanced Combine Rows feature, you can quickly combine the same items and sum the corresponding cells in another column.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. 

After installing Kutools for Excel, please do as this:

1. In order to prevent losing the original data, you’d better make a copy of the original data.

2. Then select the data range that you want to sum based on another column when cell changes.

3. Then click Kutools > Content > Advanced Combine Rows, see screenshot:

doc sum when value changes 3

4. In the Advanced Combine Rows dialog box, do the following operations:

(1.) Click the Produce column name which you want to sum values based on, and click Primary Key;

(2.) Click the Order column name that you want to sum, and then click Calculate > Sum;

(3.) Check My data has headers if you want to ignore the headers;

doc sum when value changes 4

5. Then click Ok button, all same items in column A are combined together and their corresponding cell values in column B are added up, see screenshot:

doc sum when value changes 5

Click Free Download Kutools for Excel Now!

Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.