简体   繁体   中英

Excel Sum Similar Rows via Macros

I found an answer similar to my question on these boards. However, my data is setup differently and I wasn't getting the results I needed.

My data in Excel looks like the following:

ParcelNumber    BillNumber      OwnerName     Code  Year   DollarAmount
111222          9117222         Smith, Bill   22    2013   $999
111222          9117222         Smith, Bill   22    2013   $276
111222          9117222         Smith, Bill   22    2013   $100
111223          9110001         Tan, Steve    22    2013   $96
111223          9110001         Tan, Steve    22    2013   $12
111224          9112396         Bishop, John  22    2013   $126
111225          9113333         Fidel, Jason  22    2013   $990

I need to do the following:

For all of the Parcel numbers that are the same, total up the Dollar amount and consolidate one one line per parcel number. The output would look like this:

ParcelNumber    BillNumber     OwnerName     Code    Year   DollarAmount
111222          9117222        Smith, Bill   20      2013   $1375
111223          9110001        Tan, Steve    20      2013   $108
111224          9112396        Bishop, John  20      2013   $126
111225          9113333        Fidel, Jason  20      2013   $990

Thank you very much.

Warning: Quite a lot of images coming...

Okay, select your entire table and go to Insert > PivotTable and click OK in the wizard.

  1. Click, drag and drop all the fields but the last one from the right pane to the box in the lower left. The last field goes in the box in the lower right. You should get something like this:

    在此处输入图片说明

  2. Go to PivotTable Design and in Layout , pick Show in Tabular Form and Do not show subtotals .

    在此处输入图片说明在此处输入图片说明

    And you should be done! You can copy the information you need to another sheet as required.

    在此处输入图片说明

If the amounts aren't displaying properly, make sure that the calculation is "Sum" and not "Count". You get "Count" as default if there is a non-numeric cell in the column you are pivoting. To change the calculation, simply right click on any number in the pivot table, go to 'Summarize data by' and check 'Sum'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM