# Calculation based on previous transactions

#### punnu07

##### New Member
Hi,

I have a problem to solve.

I have a data set of 7000 transactions and I need to calculate the amount for each transaction as per below formula. Please note that calculation will be done basis of account number.

 Account Number Value Percentage Amount ABC 1000 0.1 =(B2)*C2-0 ABC 1000 0.15 =(B3+B2)*C3-(D2) ABC 1000 0.05 =(B4+B3+B2)*C4-(D3+D2) DEF 1000 0.1 =(B5)*C5-0 DEF 1000 0.15 =(B6+B5)*C6-(D5) DEF 1000 0.05 =(B7+B6+B5)*C7-(D6+D5) DEF 1000 0.1 =(B8+B7+B6+B5)*C8-(D7+D6+D5) QWE 1000 0.15 =(B9)*C9-0 QWE 1000 0.05 =(B10+B9)*C10-(D9) QWE 1000 0.1 =(B11+B10+B9)*C11-(D10+D9) QWE 1000 0.15 =(B12+B11+B10+B9)*C12-(D11+D10+D9) QWE 1000 0.05 =(B13+B12+B11+B10+B9)*C13-(D12+D11+D10+D9) QWE 1000 0.1 =(B14+B13+B12+B11+B10+B9)*C14-(D13+D12+D11+D10+D9)

<tbody>
</tbody>

((Value of current transaction + value of all previous transactions) x NEW percentage%) - (sum of all previous values)

Can anyone please help me with a generic excel formula which can be put in all 7000 transactions or any VBA code.

### Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
put B2*C2 in D2, and

=C3*SUMIF(\$A\$2:A3,A3,\$B\$2:B3)-SUMIF(\$A\$2:A2,A3,\$D\$2:D2) in D3, copy down

Last edited:
Thank you Alan for your help. You are great.

you're welcome

Replies
4
Views
195
Replies
12
Views
342
Replies
1
Views
125
Replies
5
Views
299
Replies
3
Views
300

1,218,576
Messages
6,143,317
Members
450,477
Latest member
teresab543

### 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.

### Which adblocker are you using?

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

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