sorting duplicates Customers names by add two formulas in last column

Abdo

Board Regular
Joined
May 16, 2022
Messages
183
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi experts,
I need using sorting way to deal with big data for about 1000 customers and 25000 rows when repeat many times . in Customer sheet contains NAMES and in column BALANCE subtract column DEBIT fro CREDIT , but there are some the same customers are existed in BALANCE sheet . so when copy the amounts from column DEBIT or CREDIT from BALANCE sheet to column DEBIT or CREDIT in CUSTOMER sheet for the same customer is existed in CUSTOMER sheet then will add two formulas in BALANCE column for each customer when sorting duplicates customer in CUSTOMER sheet , if there is just customer in BALANCE sheet without is existed for the same customer in CUSTOMER sheet also should show in CUSTOMER sheet . as to empty cell or zero cell in column BALANCE for BALANCE sheet for the same customer is existed in CUSTOMER sheet then no need to show in CUSTOMER sheet .when brings the balance from BALANCE sheet should populate sheet name in column C for CUSTOMER sheet , date in column A based on date in column A , name in column B based on the name in column B the for BALANCE sheet . if there is just customer in BALANCE sheet without is existed for the same customer in CUSTOMER sheet also should show in CUSTOMER sheet and add one formula by subtract DEBIT from CREDIT as abddo nv customer ,if there is just customer in CUSTOMER sheet without is existed for the same customer in CUSTOMER sheet also should show in CUSTOMER sheet and add one formula by subtract DEBIT from CREDIT as abb yu customer .
add formula.xlsm
ABCDEF
1DATENAMEINFORMATIONDEBITCREDITBALANCE
201/01/2024abdo mmINV AS2202,000.00-2,000.00
302/01/2024abddo nnINV SDER 20004,000.00-4,000.00
403/01/2024abed aswINV CVFG 1231,200.00-1,200.00
504/01/2024abdo mmpaid0.00500.00-500.00
605/01/2024abddo nnpaid0.00300.00-300.00
706/01/2024abdo mmpaid-200.00-200.00
807/01/2024abddo niINV CVFR52,000.00-2,000.00
907/01/2024abb yuINV 23222,000.00-2,000.00
10TOTAL11,200.001,000.0010,200.00
CUSTOMER
Cell Formulas
RangeFormula
F2:F10F2=D2-E2
D10:E10D10=SUM(D2:D9)


add formula.xlsm
ABCDE
1DATENAMEDEBITCREDITBALANCE
231/12/2023abdo mm20,000.00-20,000.00
331/12/2023abddo nn-10,000.00-10,000.00
431/12/2023abed asw--0.00
531/12/2023abdo mj--0.00
631/12/2023abddo nv15,000.00-15,000.00
731/12/2023abddo ni-0.00
BALANCE
Cell Formulas
RangeFormula
E2:E7E2=C2-D2





result should be like this

add formula.xlsm
ABCDEF
1DATENAMEINFORMATIONDEBITCREDITBALANCE
2 31/12/2023abdo mmBALANCE 20,000.00-20,000.00
301/01/2024abdo mmINV AS2202,000.00-22,000.00
404/01/2024abdo mmpaid0.00500.0021,500.00
506/01/2024abdo mmpaid-200.0021,300.00
6 31/12/2023abddo nnBALANCE -10,000.00-10,000.00
702/01/2024abddo nnINV SDER 20004,000.00--6,000.00
805/01/2024abddo nnpaid0.00300.00-6,300.00
903/01/2024abed aswINV CVFG 1231,200.00-1,200.00
1007/01/2024abddo niINV CVFR52,000.00-2,000.00
11 31/12/2023abddo nvBALANCE 15,000.00-15,000.00
1207/01/2024abb yuINV 23222,000.00-2,000.00
13TOTAL46,200.0011,000.0035,200.00
CUSTOMER
Cell Formulas
RangeFormula
F2,F9:F13,F6F2=D2-E2
F7:F8,F3:F5F3=F2+D3-E3
D13:E13D13=SUM(D2:D12)


any help to achieve that,please?
 
Last edited:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try power query, added information column in Balances sheet and just entered Balance on all rows, import workbook with both sheets into PQ , append, group by name as per code below.
On the balances sheet in PQ filter out Balances = 0 as you don't want them
l
Power Query:
et
    Source = Excel.Workbook(File.Contents("C:\Users\USERNAME\Documents\Customer File.xlsx"), null, true),
    Balance_Sheet = Source{[Item="Balance",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Balance_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"DATE", type date}, {"NAME", type text}, {"INFORMATION", type text}, {"DEBIT", Int64.Type}, {"CREDIT", Int64.Type}, {"BALANCE", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([BALANCE] <> 0))
in
    #"Filtered Rows"


Book2
ABCDEF
1DATENAMEINFORMATIONDEBITCREDITBALANCE
231/12/23abdo mmBALANCE20000020000
301/01/24abdo mmINV AS220200002000
404/01/24abdo mmpaid0500-500
506/01/24abdo mmpaid0200-200
631/12/23abddo nnBALANCE010000-10000
702/01/24abddo nnINV SDER 2000400004000
805/01/24abddo nnpaid0300-300
931/12/23abddo nvBALANCE15000015000
1003/01/24abed aswINV CVFG 123120001200
1107/01/24abddo niINV CVFR5200002000
1207/01/24abb yuINV 2322200002000
13TOTAL462001100035200
Append1
Cell Formulas
RangeFormula
D13D13=SUM([DEBIT])
E13E13=SUM([CREDIT])
F13F13=SUM([BALANCE])


Power Query:
let
    Source = Table.Combine({Balance, Customer}),
    #"Grouped Rows" = Table.Group(Source, {"NAME"}, {{"Name.1", each _, type table [DATE=any, NAME=nullable text, INFORMATION=nullable text, DEBIT=nullable number, CREDIT=nullable number, BALANCE=nullable number]}}),
    #"Removed Columns" = Table.RemoveColumns(#"Grouped Rows",{"NAME"}),
    #"Expanded Name.1" = Table.ExpandTableColumn(#"Removed Columns", "Name.1", {"DATE", "NAME", "INFORMATION", "DEBIT", "CREDIT", "BALANCE"}, {"DATE", "NAME", "INFORMATION", "DEBIT", "CREDIT", "BALANCE"}),
    #"Removed Bottom Rows" = Table.RemoveLastN(#"Expanded Name.1",1)
in
    #"Removed Bottom Rows"
 
Upvote 0
Hi
I need vba because not always use 2019 version ,sometimes use 2010 as in my profile.
by the way the formula in BALANCE column by use PQ is not as I posted in OP.
thanks
 
Upvote 0
OK no problem someone will probably give you a VBA solution, balance column running total is easy fix in PQ but as you don't need it.. moving on ....
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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