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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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.


A
B
C
D
E
1
Account #
”Period:”
Date of Inv
Total Activity $ for period
Account Name
Accounting Period
Invoice #
”Ending Bal”

“Begin Bal”
Customer Name
Ending Bal $

Beg Bal $
Source

Invoice $
2





3
4108-02
SALES-S



4
Period:
2019-4
Begin Bal
($3,550.00)

5
30-Apr-19
G10747
PORA
AR Inv
($475.00)
6
30-Apr-19
G10747
PORA
AR Inv
($1,012.50)
7
($1,487.50)
Ending Bal
($5,037.50)


8





9
4108-04
SALES-ST



10
Period:
2019-4
Begin Bal
$0.00

11
00-Jan-00



$0.00
12
$0.00
Ending Bal
$0.00








12
4110-04
SALES-SV



13
Period:
2019-4
Beg Bal
($2,000,001.00)

14
09-Apr-19
G10701
TINKER
AR Inv
($16,312.50)
15
16-Apr-19
G10704
GERARD
AR Inv
($2,275.00)
16
16-Apr-19
G10705
SUNNY
AR Inv
($10,171.35)
17
25-Apr-19
G10706
SURGEON
AR Inv
($61,294.80)
18
29-Apr-19
G10720
AXIS
AR Inv
($10,000.00)
19
29-Apr-19
G10723
GERARD
AR Inv
($11,500.00)
20
29-Apr-19
G10724
PORA
AR Inv
($12,000.00)
21
29-Apr-19
G10725
SUNNY
AR Inv
($32,265.46)
22
29-Apr-19
G10726
SUNNY
AR Inv
($55,452.49)
23
29-Apr-19
G10728
SUNNY
AR Inv
($3,727.50)
24
30-Apr-19
G10729
APE
AR Inv
($32,300.00)
25
30-Apr-19
G10730
SURGEON
AR Inv
($3,409.63)
26
30-Apr-19
G10740
SUNNY
AR Inv
($108,450.00)
27
30-Apr-19
G10742
SUNNY
AR Inv
($9,716.50)
28
30-Apr-19
G10743
SUNNY
AR Inv
($1,551.50)
29
30-Apr-19
G10744
SUNNY
AR Inv
($5,750.00)
30
30-Apr-19
G10745
LACE
AR Inv
($119,800.00)
31
30-Apr-19
G10748
SURGEON
AR Inv
($71,169.00)
32
30-Apr-19
G10749
SURGEON
AR Inv
($60,000.00)
33
($627,145.73)
Ending Bal
($2,687,217.73)



<tbody>
</tbody>
 
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,214,635
Messages
6,120,660
Members
448,975
Latest member
sweeberry

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