Distributing an amount across entries in listbox

fraufreda

Board Regular
Joined
Oct 14, 2010
Messages
190
I have 3 listboxes. The first one contains names, reference, and negative values. The second is structured the same way but with positive values. what I am trying to do is to loop through each row in listbox1 and check if the name exists in listbox2 and then if found distribute the negative value across the positive ones and put in listbox3


ListBox1

Name1, Ref1, -90
Name1, Ref2, -30
Name2, Ref3, -40

Listbox2

Name1, Ref4, 50
Name1, Ref5, 30
Name1, Ref6, 70

Listbox3

Name1, Ref1, Ref4, 50 'remaining value -90+50 = -40 .. remove item from listbox2
Name1. Ref1, Ref5, 30 'Remaining value -90+50+30 = -10 .. remove item from listbox2
Name1, Ref1, Ref6, 10 'Remaining value -90+50+30+10 = 0 .. Keep item in listbox2 but change the value from 70 to 70 - 10 = 60 or 50+30+70-90=60

then loop through the next item in listbox1 and do the same
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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