VBA for subtotal or is there another easier way?

cytochrome

New Member
Joined
Feb 8, 2017
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hi there,
I have a spreadsheet looked like below.

CODEAccountPaydateNetGrossCurrency
123​
ABC
20221216​
1​
5​
USD
360206​
DEF
20221217​
2​
10​
CAD
123​
ABC
20221216​
10​
15​
USD
360206​
GHI
20221216​
20​
20​
USD

I dont know if VBA is better or using existing functions in Excel. But im looking to total the Net and Gross column if CODE, Account, Paydate, Currency are the same. So should look something like below. The new table should be on another sheet. Any help is greatly appreaciated.

CODEAccountPaydateNetGrossCurrency
123​
ABC
20221216​
11​
20​
USD
360206​
DEF
20221217​
2​
10​
CAD
360206​
GHI
20221216​
20​
20​
USD
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi,
Have you tried to insert a Pivot Table ?
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Just update. I'm using Excel 365.
 
Upvote 0
I thought of using Pivot Table but the resulting data doesn't look that clean. Plus my actual spreadsheet has 100,000+ lines on it so it takes awhile for Pivot Table to update.
 
Upvote 0
How about
Fluff.xlsm
ABCDEFG
1CODEAccountPaydateNetGrossCurrency
2123ABC2022121615USD
3360206DEF20221217210CAD
4123ABC202212161015USD
5360206GHI202212162020USD
6
Sheet1


Fluff.xlsm
ABCDEFG
1CODEAccountPaydateNetGrossCurrency
2123ABC202212161120USD
3360206DEF20221217210CAD
4360206GHI202212162020USD
5
Sheet2
Cell Formulas
RangeFormula
A2:G4A2=LET(u,UNIQUE(CHOOSECOLS(FILTER(Sheet1!A2:G500,Sheet1!A2:A500<>""),1,2,3,7)),HSTACK(TAKE(u,,3),SUMIFS(Sheet1!D:D,Sheet1!A:A,INDEX(u,,1),Sheet1!B:B,INDEX(u,,2),Sheet1!C:C,INDEX(u,,3),Sheet1!G:G,INDEX(u,,4)),EXPAND("",ROWS(u),,""),SUMIFS(Sheet1!F:F,Sheet1!A:A,INDEX(u,,1),Sheet1!B:B,INDEX(u,,2),Sheet1!C:C,INDEX(u,,3),Sheet1!G:G,INDEX(u,,4)),TAKE(u,,-1)))
Dynamic array formulas.
 
Upvote 0
Wow that works! AMAZING! Thank you!!!!!
I'm guessing the formula will work for 500 rows of data on Sheet2 right? And I'm also guessing your logic for the solution is Dynamic Array? If so then i will definitely need to learn more about it as it's some neat stuff.

Again thank you for your help.
 
Upvote 0

Forum statistics

Threads
1,215,200
Messages
6,123,612
Members
449,109
Latest member
Sebas8956

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