populate amounts for column debit,credit for each customer from file to another

KalilMe

Active Member
Joined
Mar 5, 2021
Messages
354
Office Version
  1. 2016
Platform
  1. Windows
Hello
I search for macro to deal 3000 rows for about 5 sheets for INVOICE file and about 15 sheets CUSTOMERS for CUSTOMER file
INVOICE file contents .

INVOICE.xlsm
ABCDEFGHIJ
1ITEMDATENAMEINVOICEGOODSTYPEPRQTYUNITTOTAL
2126/07/2023CR-1000STVG-1000ATRAM1MTR5.0025.00125.00
3226/07/2023CR-1000STVG-1000ATRAM2PO4.0035.00140.00
4326/07/2023CR-1000STVG-1000ATRAM1SO2.0045.0090.00
5TOTAL26/07/2023CR-1000STVG-1000355.00
6126/07/2023CR-1001STVG-1001ATRAM1GR2.0023.0046.00
7226/07/2023CR-1001STVG-1001ATRAM2PO2.0035.0070.00
8TOTAL26/07/2023CR-1001STVG-1001116.00
9127/07/2023CR-1000STVG-1002ATRAM1MTR2.0025.0050.00
10227/07/2023CR-1000STVG-1002ATRAM2PO2.0035.0070.00
11327/07/2023CR-1000STVG-1002ATRAM1SO2.0045.0090.00
12TOTAL27/07/2023CR-1000STVG-1002210.00
BUYING


INVOICE.xlsm
ABCDEFGHIJ
1ITEMDATENAMEINVOICEGOODSTYPEPRQTYUNITTOTAL
2126/08/2023CR-1000FRVG-10000ATRAM1GR10.0010.00100.00
3226/08/2023CR-1000FRVG-10000ATRAM2PO10.0020.00200.00
4TOTAL26/08/2023CR-1000FRVG-10000300.00
5126/08/2023CR-1001FRVG-10001ATRAM1GR10.0022.00220.00
6226/08/2023CR-1001FRVG-10001ATRAM2PO10.0033.00330.00
7TOTAL26/08/2023CR-1001FRVG-10001550.00
8126/08/2023CR-1002FRVG-10002ATRAM1GR10.0010.00100.00
9226/08/2023CR-1002FRVG-10002ATRAM1PO20.0010.00200.00
10326/08/2023CR-1002FRVG-10002ATRAM4QW10.00200.002,000.00
11TOTAL26/08/2023CR-1002FRVG-100022,300.00
12126/08/2023CR-1000FRVG-10003ATRAM1GR20.00100.002,000.00
13226/08/2023CR-1000FRVG-10003ATRAM1PO20.00200.004,000.00
14326/08/2023CR-1000FRVG-10003ATRAM4QW200.00100.0020,000.00
15TOTAL26/08/2023CR-1000FRVG-1000326,000.00
SALES



INVOICE.xlsm
ABCDEFGHIJ
1ITEMDATENAMEINVOICEGOODSTYPEPRQTYUNITTOTAL
2129/07/2023CR-1000RTSTVG-1000ATRAM1SO2.0045.0090.00
3TOTAL29/07/2023CR-1000RTSTVG-100090.00
4129/07/2023CR-1000RTSTVG-1001ATRAM1MTR2.0025.0050.00
5TOTAL29/07/2023CR-1000RTSTVG-100150.00
BUYING RETURN



INVOICE.xlsm
ABCDEFGHIJ
1ITEMDATENAMEINVOICEGOODSTYPEPRQTYUNITTOTAL
2130/10/2023CR-1000SRTFRVG-10001ATRAM1GR10.0022.00220.00
3TOTAL30/10/2023CR-1000SRTFRVG-10001220.00
4130/10/2023CR-1002SRTFRVG-10002ATRAM4QW10.00200.002,000.00
5230/10/2023CR-1002SRTFRVG-10002ATRAM1PO20.0010.00200.00
6TOTAL30/10/2023CR-1002SRTFRVG-100022,200.00
SALES RETURNS



INVOICE.xlsm
ABCDEFGH
2DATEVOUCHER NO
327/09/2023VTR-110INVOICE
4NAMESALES
5CR-1000TOTAL
6300
VOUCHER



CUSTOMER file contents
CUSTOMERS.xlsm
ABCDE
1DATEDETAILSDEBITCREDITBALANCE
20.00
30.00
4TOTAL0.000.000.00
CR-1000
Cell Formulas
RangeFormula
E2,E4E2=C2-D2
E3E3=E2+C3-D3
C4:D4C4=SUM(C2:C3)


CUSTOMERS.xlsm
ABCDE
1DATEDETAILSDEBITCREDITBALANCE
20.00
30.00
4TOTAL0.000.000.00
CR-1001
Cell Formulas
RangeFormula
E2,E4E2=C2-D2
E3E3=E2+C3-D3
C4:D4C4=SUM(C2:C3)


CUSTOMERS.xlsm
ABCDE
1DATEDETAILSDEBITCREDITBALANCE
20.00
30.00
4TOTAL0.000.000.00
CR-1002
Cell Formulas
RangeFormula
E2,E4E2=C2-D2
E3E3=E2+C3-D3
C4:D4C4=SUM(C2:C3)

so should match NAME in column C for 1,2,3 sheets in INVOICE file with sheet name in CUSTOMERS file then populate data in all of sheets in CUSTOMERS file .
should copy the date from column(B) and INVOICE in column D and TOTAL in column G from the TOTAL (lastrow ) from BUYING sheet in INVOICE file and put DATE,INVOICE in column A,B in CUSTOMERS file and put amount in column D(CREDIT) in CUSTOMERS file ,should copy the date from column(B) and INVOICE in column D and TOTAL in column G from the TOTAL (lastrow ) from SALES sheet in INVOICE file and put DATE,INVOICE in column A,B in CUSTOMERS file and put amount in column C(DEBIT) in CUSTOMERS file , should copy the date from column(B) and INVOICE in column D and TOTAL in column G from the TOTAL (lastrow ) from BUYING RETURN sheet in INVOICE file and put DATE,INVOICE in column A,B in CUSTOMERS file and put amount in column C(DEBIT) in CUSTOMERS file , should copy the date from column(B) and INVOICE in column D and TOTAL in column G from the TOTAL (lastrow ) from SALES RETURN sheet in INVOICE file and put DATE,INVOICE in column A,B in CUSTOMERS file and put amount in column D(CREDIT ) in CUSTOMERS file ,as to VOUCHER sheet should match custmer name in C5 with sheet name in CUSTOMMERS file ,if the cell F4 is SALES thin will put in column C(DEBIT) in CUSTOMMERS FILE and copy DATE,VOUCHER NO from VOUCHER sheet and put in columns A,B
here is result
CUSTOMERS.xlsm
ABCDE
1DATEDETAILSDEBITCREDITBALANCE
226/07/2023STVG-1000355.00-355.00
327/07/2023STVG-1002210.00-565.00
426/08/2023FRVG-10000300.00-265.00
526/08/2023FRVG-1000326,000.0025,735.00
629/07/2023RTSTVG-100090.0025,825.00
729/07/2023RTSTVG-100150.0025,875.00
827/09/2023VTR-110300.0026,175.00
930/10/2023SRTFRVG-10001220.0025,955.00
10TOTAL26,740.00785.0025,955.00
CR-1000
Cell Formulas
RangeFormula
E2,E10E2=C2-D2
E3:E9E3=E2+C3-D3
C10:D10C10=SUM(C2:C9)

but there is another case about VOUCHER sheet for INVOICE file , if the cell F4 is BUYING then will put the amount from H6 and put in column D (CREDIT) for CUSTOMERS file like this
INVOICE.xlsm
ABCDEFGH
2DATEVOUCHER NO
327/11/2023STR-556INVOICE
4NAMEBUYING
5CR-1000TOTAL
6250
7
VOUCHER


result
CUSTOMERS.xlsm
ABCDE
1DATEDETAILSDEBITCREDITBALANCE
226/07/2023STVG-1000355.00-355.00
327/07/2023STVG-1002210.00-565.00
426/08/2023FRVG-10000300.00-265.00
526/08/2023FRVG-1000326,000.0025,735.00
629/07/2023RTSTVG-100090.0025,825.00
729/07/2023RTSTVG-100150.0025,875.00
827/09/2023VTR-110300.0026,175.00
930/10/2023SRTFRVG-10001220.0025,955.00
1027/11/2023STR-556250.0025,705.00
11TOTAL26,740.001,035.0025,705.00
CR-1000
Cell Formulas
RangeFormula
E2,E11E2=C2-D2
E3:E10E3=E2+C3-D3
C11:D11C11=SUM(C2:C10)

two files are xlsm extensions , existed in the same folder .
every time I want clear data except formulas for each customer in CUSTOMER file before bring data and should clear cells in VOUCHER sheet when copy to CUSTOMERS file ,also should add formulas when add new data before TOTAL row for each customer as showing in CR-1000 customer in CUSTOMERS files
I want doing the same thing for the rest of customers in CUSTOMERS file by
I hope find this macro by help experts .
thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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