Sum array (or something) based on multiple criteria

NeewBie

New Member
Joined
Aug 7, 2012
Messages
40
Hi,

Have a big problem - don't know If its possible to solve it with VBA. If the socialsec, date, fruit is same then save it into a temp or something sum quantity and print out as 1 line else different rows.

Have a sheet with following data:

SocialSec Date Fruit Quantity
12345 2015-02-02 Apple 5
12345 2015-02-02 Apple 3
11223 2015-02-01 Banana 1
11223 2015-02-01 Pear 1

Printout in Sheet2:

SocialSec Date Fruit Quantity
12345 2015-02-02 Apple 8
11223 2015-02-01 Banana 1
11223 2015-02-01 Pear 1

Is this possible to solve? Best way to solve it thru an array, or? Feels impossible with VBA.

Thanks for help!
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Here's a non-VBA solution:
Enter in E2 and copy down:
Code:
=SUMIFS(D:D,A:A,A2,B:B,B2,C:C,C2)
Enter in F2 and copy down:
Code:
=IF(A2&"~"&B2&"~"&C2=A1&"~"&B1&"~"&C1,"Duplicate","Not Duplicate")
Now turn on AutoFilters and filter Col F for "Not Duplicates". Then hide Col D and put header names in E1 and F1.
 
Upvote 0
Hi,

Thank you for the help but I need an VBA-script because this will be a part of my script. Do you think its possible to solve with VBA?

Please help!

Here's a non-VBA solution:
Enter in E2 and copy down:
Code:
=SUMIFS(D:D,A:A,A2,B:B,B2,C:C,C2)
Enter in F2 and copy down:
Code:
=IF(A2&"~"&B2&"~"&C2=A1&"~"&B1&"~"&C1,"Duplicate","Not Duplicate")
Now turn on AutoFilters and filter Col F for "Not Duplicates". Then hide Col D and put header names in E1 and F1.
 
Upvote 0
Sorry, I thought your last sentence asked for an array solution. I'm not versed in VBA, perhaps another contributor can respond.
 
Upvote 0

Forum statistics

Threads
1,215,307
Messages
6,124,168
Members
449,146
Latest member
el_gazar

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