VBA Coding or macro to pull out sum for a specific account and vendor

dstepan

Board Regular
Joined
Apr 16, 2009
Messages
160
Hello to all

I'm not sure how to approach this problem.

This first table is the end result I am looking for.

The data I pull down from my accounting system is in the second table below. It exports to excel 2016 as it is shown.
It is basically a GL detail report.
I am only concerned with 4 accounts and 2 customers: see the first table below.

Can anyone tell me if this is a feasible task? And if so, how I might begin to get the end results.

Any help is greatly appreciated.

Thank you

ABC
1SUNNYSURGEON
24110-04($227,084.80)($195,873.43)
34112-04($288,937.03)($44,047.50)
44114-04($5,478.29)0
54108-0200
6
7

<tbody>
</tbody>

ABCDEFG
1DateReference*SourceTypeCurYTD
2Hunt Ck
34108-02SALES-S
4Period:2019-4Begin Bal($3,550.00)
5 30-Apr-19G10747PORAAR Inv ($475.00)
6 30-Apr-19G10747PORAAR Inv ($1,012.50)
7($1,487.50)Ending Bal($5,037.50)
84108-04SALES-ST
9Period:2019-4Begin Bal$0.00
10 00-Jan-00 $0.00
11 $0.00Ending Bal$0.00
124110-04SALES-SV
13Period:2019-4Beg Bal($2,000,001.00)
1409-Apr-19G10701TINKERAR Inv($16,312.50)
1516-Apr-19G10704GERARDAR Inv ($2,275.00)
1616-Apr-19G10705SUNNYAR Inv($10,171.35)
1725-Apr-19G10706SURGEONAR Inv($61,294.80)
1829-Apr-19G10720AXISAR Inv($10,000.00)
1929-Apr-19G10723GERARDAR Inv($11,500.00)
2029-Apr-19G10724PORAAR Inv($12,000.00)
2129-Apr-19G10725SUNNYAR Inv($32,265.46)
2229-Apr-19G10726SUNNYAR Inv($55,452.49)
2329-Apr-19G10728SUNNYAR Inv ($3,727.50)
2430-Apr-19G10729APEAR Inv($32,300.00)
2530-Apr-19G10730SURGEONAR Inv ($3,409.63)
2630-Apr-19G10740SUNNYAR Inv($108,450.00)
2730-Apr-19G10742SUNNYAR Inv ($9,716.50)
2830-Apr-19G10743SUNNYAR Inv ($1,551.50)
2930-Apr-19G10744SUNNYAR Inv ($5,750.00)
3030-Apr-19G10745LACEAR Inv($119,800.00)
3130-Apr-19G10748SURGEONAR Inv ($71,169.00)
3230-Apr-19G10749SURGEONAR Inv ($60,000.00)
33($627,145.73Ending Bal($2,687,217.73)
344112-04SALES-P
35Period:2019-4Beg Bal($785,976.81)
3621-Apr-19G10709SUNNYAR Inv($196,030.98)
3730-Apr-19G10739SUNNYAR Inv ($92,906.05)
3830-Apr-19G10741SURGEONAR Inv ($44,047.50)
39($332,984.53)Ending Bal($1,118,961.34)
404114-04SALES -P
41Period:2019-04Beg Bal($53,679.42)
42G10700GREENAR Inv($4,545.00)
43G10738SUNNYAR Inv($5,478.29
44($10,023.29)Ending Bal($63,702.71)

<tbody>
</tbody>
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
How do you get those number if, for example, SUNNY isn't associated with ANY 4110-04 in the A-column?

And, ultimately, what column are you totaling? D or E ?
 
Upvote 0
I got this array formula (CTRL+SHIFT+Enter) to work. I found that using SUMPRODUCT also needed to be an array formula. I placed the code in the report table in B2 and filled across to C2.
You'll have to change the B$1 to fill down.

Code:
=SUM((B$1=IF(ISTEXT(GL_Detail!$C$1:$C$50),GL_Detail!$C$1:$C$50," "))*($A2=IF(ISTEXT(GL_Detail!$A$1:$A$50),GL_Detail!$A$1:$A$50," "))*(IF(ISNUMBER(GL_Detail!$E$1:$E$50),GL_Detail!$E$1:$E$50,0)))

Code:
=SUMPRODUCT(--(B$1=IF(ISTEXT(GL_Detail!$C$1:$C$50),GL_Detail!$C$1:$C$50," "))*(--($A2=IF(ISTEXT(GL_Detail!$A$1:$A$50),GL_Detail!$A$1:$A$50," ")))*(IF(ISNUMBER(GL_Detail!$E$1:$E$50),GL_Detail!$E$1:$E$50,0)))

But I had to change the A column of the GL_Detail to have some types like 4110-04 match the people, etc.

BTW: these both total the E column.
 
Last edited:
Upvote 0
So, I tried to clean up the report to give you a better picture of what I am trying to get to. I didn't include the account number 4114-04.
I inserted a row between each account number.
Row 1 shows the first line, 2nd line, Body, and last line of each account number.
I am concerned with the related invoice amount for each of the customer names - Sunny and Surgeon, within each account number.
See the first table in original thread.

[TABLE="width: 702"]
<tbody>[TR]
[TD]
[/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Account #
”Period:”
Date of Inv
Total Activity $ for period
[/TD]
[TD]Account Name
Accounting Period
Invoice #
”Ending Bal”
[/TD]
[TD]
“Begin Bal”
Customer Name
Ending Bal $
[/TD]
[TD]
Beg Bal $
Source
[/TD]
[TD]
Invoice $
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]4108-02
[/TD]
[TD]SALES-S
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Period:
[/TD]
[TD]2019-4
[/TD]
[TD]Begin Bal
[/TD]
[TD]($3,550.00)
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD] 30-Apr-19
[/TD]
[TD]G10747
[/TD]
[TD]PORA
[/TD]
[TD]AR Inv
[/TD]
[TD] ($475.00)
[/TD]
[/TR]
[TR]
[TD]6
[/TD]
[TD] 30-Apr-19
[/TD]
[TD]G10747
[/TD]
[TD]PORA
[/TD]
[TD]AR Inv
[/TD]
[TD] ($1,012.50)
[/TD]
[/TR]
[TR]
[TD]7
[/TD]
[TD] ($1,487.50)
[/TD]
[TD]Ending Bal
[/TD]
[TD]($5,037.50)
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]8
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]9
[/TD]
[TD]4108-04
[/TD]
[TD]SALES-ST
[/TD]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Apr-19
[/TD]
[TD]G10720
[/TD]
[TD]AXIS
[/TD]
[TD]AR Inv
[/TD]
[TD]($10,000.00)
[/TD]
[/TR]
[TR]
[TD]19
[/TD]
[TD]29-Apr-19
[/TD]
[TD]G10723
[/TD]
[TD]GERARD
[/TD]
[TD]AR Inv
[/TD]
[TD]($11,500.00)
[/TD]
[/TR]
[TR]
[TD]20
[/TD]
[TD]29-Apr-19
[/TD]
[TD]G10724
[/TD]
[TD]PORA
[/TD]
[TD]AR Inv
[/TD]
[TD]($12,000.00)
[/TD]
[/TR]
[TR]
[TD]21
[/TD]
[TD]29-Apr-19
[/TD]
[TD]G10725
[/TD]
[TD]SUNNY
[/TD]
[TD]AR Inv
[/TD]
[TD]($32,265.46)
[/TD]
[/TR]
[TR]
[TD]22
[/TD]
[TD]29-Apr-19
[/TD]
[TD]G10726
[/TD]
[TD]SUNNY
[/TD]
[TD]AR Inv
[/TD]
[TD]($55,452.49)
[/TD]
[/TR]
[TR]
[TD]23
[/TD]
[TD]29-Apr-19
[/TD]
[TD]G10728
[/TD]
[TD]SUNNY
[/TD]
[TD]AR Inv
[/TD]
[TD] ($3,727.50)
[/TD]
[/TR]
[TR]
[TD]24
[/TD]
[TD]30-Apr-19
[/TD]
[TD]G10729
[/TD]
[TD]APE
[/TD]
[TD]AR Inv
[/TD]
[TD]($32,300.00)
[/TD]
[/TR]
[TR]
[TD]25
[/TD]
[TD]30-Apr-19
[/TD]
[TD]G10730
[/TD]
[TD]SURGEON
[/TD]
[TD]AR Inv
[/TD]
[TD] ($3,409.63)
[/TD]
[/TR]
[TR]
[TD]26
[/TD]
[TD]30-Apr-19
[/TD]
[TD]G10740
[/TD]
[TD]SUNNY
[/TD]
[TD]AR Inv
[/TD]
[TD]($108,450.00)
[/TD]
[/TR]
[TR]
[TD]27
[/TD]
[TD]30-Apr-19
[/TD]
[TD]G10742
[/TD]
[TD]SUNNY
[/TD]
[TD]AR Inv
[/TD]
[TD] ($9,716.50)
[/TD]
[/TR]
[TR]
[TD]28
[/TD]
[TD]30-Apr-19
[/TD]
[TD]G10743
[/TD]
[TD]SUNNY
[/TD]
[TD]AR Inv
[/TD]
[TD] ($1,551.50)
[/TD]
[/TR]
[TR]
[TD]29
[/TD]
[TD]30-Apr-19
[/TD]
[TD]G10744
[/TD]
[TD]SUNNY
[/TD]
[TD]AR Inv
[/TD]
[TD] ($5,750.00)
[/TD]
[/TR]
[TR]
[TD]30
[/TD]
[TD]30-Apr-19
[/TD]
[TD]G10745
[/TD]
[TD]LACE
[/TD]
[TD]AR Inv
[/TD]
[TD]($119,800.00)
[/TD]
[/TR]
[TR]
[TD]31
[/TD]
[TD]30-Apr-19
[/TD]
[TD]G10748
[/TD]
[TD]SURGEON
[/TD]
[TD]AR Inv
[/TD]
[TD] ($71,169.00)
[/TD]
[/TR]
[TR]
[TD]32
[/TD]
[TD]30-Apr-19
[/TD]
[TD]G10749
[/TD]
[TD]SURGEON
[/TD]
[TD]AR Inv
[/TD]
[TD] ($60,000.00)
[/TD]
[/TR]
[TR]
[TD]33
[/TD]
[TD]($627,145.73)
[/TD]
[TD]Ending Bal
[/TD]
[TD]($2,687,217.73)
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
I think I understand it now.

I placed your data in a sheet starting in A1. That meant that 4108-02 was in A2.
I then created a helper column starting in H2:

Code:
=IF(OR(A2="4108-02",A2="4108-04",A2="4114-04",A2="4110-04",A2="4112-04"),A2,H1)

Starting in J2, I put the report table (e.g., SUNNY is in K2 and the A/N are in J3:J6).
In the cell below SUNNY (K3), I used this formula which I filled down and across (to SURGEON):

Code:
=SUMIFS($E$2:$E$43,$H$2:$H$43,$J3,$C$2:$C$43,K$2)

Since I cannot post an Excel file, you'll have to see if you follow this and get the results you want. I did.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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