Filtering Data and Sum the Values in the Adjacent Column

madhuchelliah

Board Regular
Joined
Nov 22, 2017
Messages
226
Office Version
  1. 2019
Platform
  1. Windows
Hello Folks, i am preparing the sales report of books. I want to filter a book name in column C and want to add the number of books sold. the result should be in next sheet column C book name and column D total sold quantity. Please see the example below.

C
D
Book A
1
Book B
3
Book C
4
Book A
5
Book C
2
Book A
6
Book C
2
Book B
1
Book D
5

<tbody>
</tbody>
C
D
Book A
12
Book B
4
Book C
8
Book D
5

<tbody>
</tbody>
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
use PivotTable and put it on sheet2 or anywhere you want

BookSoldBookSum of Sold
Book A
1​
Book A
12​
Book B
3​
Book B
4​
Book C
4​
Book C
8​
Book A
5​
Book D
5​
Book C
2​
Grand Total
29
Book A
6​
Book C
2​
Book B
1​
Book D
5​
 
Last edited:
Upvote 0
use PivotTable and put it on sheet2 or whereever you want

Thanks for your suggestion. But i am running batch of macros to complete a process. This is one among that, so i think macros is the good solution.
 
Upvote 0
I do not see any mention of vba in the title or post

have a nice day
 
Upvote 0
How about
Code:
Sub madhuchelliah()
   Dim Cl As Range
   
   With CreateObject("scripting.dictionary")
      .comparemode = 1
      For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = .Item(Cl.Value) + Cl.Offset(, 1).Value
      Next Cl
      Sheets("sheet2").Range("C2").Resize(.Count, 2).Value = Application.Transpose(Array(.Keys, .Items))
   End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top