Tracing sum cells up to match with cell in last row for another sheet

abdo meghari

Well-known Member
Joined
Aug 3, 2021
Messages
650
Office Version
  1. 2019
Hello

I have INVOICE sheet contains TOTAL amount in last row for column E should match with column C in ACCOUNT sheet after summing .

when sum the amounts for column C should stop from summing at lastrow match with same amount in INVOICE sheet .when reach for the same amount in last row for column E in INVOICE sheet after that copy summing amount from column C and put in in column F for last cell ACCOUNT sheet.

ورقة عمل Microsoft Excel جديد.xlsx
ABCDE
21ITEMBRANDQTYPRICEBALANCE
221VEGA 70A R KOR4.00500.002,000.00
232VEGA 55A R KOR2.00425.00850.00
243LARGEST 60A L HIGH JAP2.00440.00880.00
254KM 215/65R16 TA31 KOR4.00460.001,840.00
265265/70R16 ALGERIA4.00630.002,520.00
276KM 205/65R16 HS63 KOR4.00445.001,780.00
287GC 385/65R22.5 AT131 CHI2.001,650.003,300.00
298KM 265/70R16 KOR4.00880.003,520.00
309DONGA 66A L KOR2.00460.00920.00
3110KM 235/65R17 HP71 KOR4.00625.002,500.00
3211KM 235/55R19 PS71 KOR4.00675.002,700.00
3312DROUB 90A L KOR1.00575.00575.00
3413KM 13R22.5 MA11 KOR2.002,550.005,100.00
35TOTAL39.0028,485.00
INVOICE
Cell Formulas
RangeFormula
C35,E35C35=SUM(C22:C34)
E22:E34E22=D22*C22



ورقة عمل Microsoft Excel جديد.xlsx
ABCDEF
1DATEINFODEBITCREDITBALANCENOTE
201/11/2024SALES INVOICE NO BSJ20002,000.002,000.00
302/11/2024SALES INVOICE NO BSJ20013,000.005,000.00
403/11/2024SALES RETURNS INVOICE NO BSJ7893,000.002,000.00
503/11/2024VOUCHER NO VBGH67881,500.00500.00
604/11/2024SALES INVOICE NO BSJ200315,000.0015,500.00
704/11/2024SALES INVOICE NO BSJ20048,485.0023,985.00
805/11/2024SALES INVOICE NO BSJ200512,000.0035,985.00
906/11/2024SALES INVOICE NO BSJ200612,000.0047,985.00
ACCOUNT
Cell Formulas
RangeFormula
E2E2=C2-D2
E3,E5:E9E3=E2+C3-D3
E4E4=E3+CC104-D4




result

ورقة عمل Microsoft Excel جديد.xlsx
ABCDEF
1DATEINFODEBITCREDITBALANCENOTE
201/11/2024SALES INVOICE NO BSJ20002,000.002,000.00
302/11/2024SALES INVOICE NO BSJ20013,000.005,000.00
403/11/2024SALES RETURNS INVOICE NO BSJ7893,000.002,000.00
503/11/2024VOUCHER NO VBGH67881,500.00500.00
604/11/2024SALES INVOICE NO BSJ200315,000.0015,500.00
704/11/2024SALES INVOICE NO BSJ20048,485.0023,985.0028,485.00
805/11/2024SALES INVOICE NO BSJ200512,000.0035,985.00
906/11/2024SALES INVOICE NO BSJ200612,000.0047,985.00
ACCOUNT
Cell Formulas
RangeFormula
E2E2=C2-D2
E3,E5:E9E3=E2+C3-D3
E4E4=E3+CC104-D4



if write another process
ورقة عمل Microsoft Excel جديد.xlsx
ABCDE
21ITEMBRANDQTYPRICEBALANCE
221VEGA 70A R KOR4.00500.002,000.00
234KM 215/65R16 TA31 KOR4.00460.001,840.00
245265/70R16 ALGERIA4.00630.002,520.00
257GC 385/65R22.5 AT131 CHI2.001,650.003,300.00
268KM 265/70R16 KOR4.001,010.004,040.00
2710KM 235/65R17 HP71 KOR4.00625.002,500.00
2811KM 235/55R19 PS71 KOR4.00675.002,700.00
2913KM 13R22.5 MA11 KOR2.002,550.005,100.00
30TOTAL28.0024,000.00
INVOICE
Cell Formulas
RangeFormula
C30,E30C30=SUM(C22:C29)
E22:E29E22=D22*C22




result
ورقة عمل Microsoft Excel جديد.xlsx
ABCDEF
1DATEINFODEBITCREDITBALANCENOTE
201/11/2024SALES INVOICE NO BSJ20002,000.002,000.00
302/11/2024SALES INVOICE NO BSJ20013,000.005,000.00
403/11/2024SALES RETURNS INVOICE NO BSJ7893,000.002,000.00
503/11/2024VOUCHER NO VBGH67881,500.00500.00
604/11/2024SALES INVOICE NO BSJ200315,000.0015,500.00
704/11/2024SALES INVOICE NO BSJ20048,485.0023,985.0028,485.00
805/11/2024SALES INVOICE NO BSJ200512,000.0035,985.00
906/11/2024SALES INVOICE NO BSJ200612,000.0047,985.0024,000.00
ACCOUNT
Cell Formulas
RangeFormula
E2E2=C2-D2
E3,E5:E9E3=E2+C3-D3
E4E4=E3+CC104-D4

always when sum for column C will match lastrow in column E for INVOICE sheet. for some reason if it's not matched for the same amount then shouldn't show any thing in column F for ACCOUNT sheet.
every time when try sum amount in column C will start from after amount is existed in column F , but from first time will start from row2.
thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try this

VBA Code:
Sub Tracing_sum()
  Dim tot As Double, dbt As Double
  Dim i As Long
  
  tot = Sheets("INVOICE").Range("E" & Rows.Count).End(3).Value
  With Sheets("ACCOUNT")
    For i = .Range("F" & Rows.Count).End(3).Row + 1 To .Range("E" & Rows.Count).End(3).Row
      dbt = dbt + .Range("C" & i).Value
      If dbt = tot Then
        .Range("F" & i).Value = tot
        Exit For
      End If
    Next
  End With
End Sub

🧙‍♂️
 
Upvote 0
Solution

Forum statistics

Threads
1,224,759
Messages
6,180,814
Members
452,996
Latest member
nelsonsix66

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