Macro sum between all positive and negative entries to reach a value

hstef

New Member
Joined
Nov 19, 2018
Messages
39
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have a column (L) with some negative and positive entries (invoices value).
I have some customers who pay thru bank and does not specify which invoices is paying. And usually do not pay in order.
All i have is paymant's total value.

I need a macro to make calculation in column "L" until it reaches the total value of payment and to highlight the cells that made up the value.
I will put the payment value in "O1".

Column L example:
[TABLE="width: 90"]
<colgroup><col></colgroup><tbody>[TR]
[TD="align: right"]203.49[/TD]
[/TR]
[TR]
[TD="align: right"]224.91[/TD]
[/TR]
[TR]
[TD="align: right"]-224.91[/TD]
[/TR]
[TR]
[TD="align: right"]239.67[/TD]
[/TR]
[TR]
[TD="align: right"]-36.48[/TD]
[/TR]
[TR]
[TD="align: right"]-203.49[/TD]
[/TR]
[TR]
[TD="align: right"]64.26[/TD]
[/TR]
[TR]
[TD="align: right"]-66.96[/TD]
[/TR]
[TR]
[TD="align: right"]24.99[/TD]
[/TR]
[TR]
[TD="align: right"]-24.99[/TD]
[/TR]
[TR]
[TD="align: right"]105.43[/TD]
[/TR]
</tbody>[/TABLE]

Can this be done?
Thank you kindly,
Stef.
 
Here's how the results look:
Excel 2010
[Table="width:, class:head"][tr=bgcolor:#888888][th]Row\Col[/th][th]
A
[/th][th]
B
[/th][th]
C
[/th][th]
D
[/th][th]
E
[/th][th]
F
[/th][th]
G
[/th][th]
H
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
1
[/td][td]Vals[/td][td]+ Count[/td][td]- Count[/td][td]Instance[/td][td]Match[/td][td][/td][td]check[/td][td]
(0.00)
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
2
[/td][td=bgcolor:#92D050]
203.49​
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
TRUE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
3
[/td][td=bgcolor:#92D050]
224.91​
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
TRUE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
4
[/td][td=bgcolor:#92D050]
(224.91)
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
TRUE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
5
[/td][td]
239.67​
[/td][td]
1​
[/td][td]
0​
[/td][td]
1​
[/td][td]
FALSE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
6
[/td][td]
(36.48)
[/td][td]
0​
[/td][td]
1​
[/td][td]
1​
[/td][td]
FALSE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
7
[/td][td=bgcolor:#92D050]
(203.49)
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
TRUE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
8
[/td][td]
64.26​
[/td][td]
1​
[/td][td]
0​
[/td][td]
1​
[/td][td]
FALSE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
9
[/td][td]
(66.96)
[/td][td]
0​
[/td][td]
1​
[/td][td]
1​
[/td][td]
FALSE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
10
[/td][td=bgcolor:#92D050]
24.99​
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
TRUE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
11
[/td][td=bgcolor:#92D050]
(24.99)
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
TRUE​
[/td][td][/td][td][/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
12
[/td][td]
105.43​
[/td][td]
1​
[/td][td]
0​
[/td][td]
1​
[/td][td]
FALSE​
[/td][td][/td][td][/td][td][/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet1[/td][/tr][/table]
 
Upvote 0

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.

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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