ramdon sum

lx

New Member
hi! i have a list of amounts on column A, and i have a total on column B, i am trying to create a program that sum the values on column A until ithe sum is equal to the amount on column b, any clue, i am really without clue about this!!

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use \$ signs: \$V\$2:\$Z\$99 will always point to V2:Z99, even after copying
Welcome:
You could add conditional formatting to highlight the last cell that is less than or equal to column B:

Click on cell A1
From the format menu, choose conditional formatting.
Choose "formula is" and type in the following:
=SUM(\$A\$1:\$A1)<=\$B\$1
Choose a format

This will highlight those cells that add up to less than the value in cell B1.

Is that the sort of thing you're after?

no that dont help what i am trying to do is this:

----A------- ---------B-----------
5000 9000
3000
1000
2000
4000

result of macro or formula: sum of a1+A5 is equal to b1 / sum of a1+a2+a3 is equal to b1. i want the posibles sum with A numbers that are equal to b1

There are a number of posts that deal with "combinations".

You could search for this and review them.

You shoud find some that allow you to list all of the combinations, which you can then add to see if they add to 9000.

but i cannot make it work, i meant it work but dont show anything just the time that it took can someone help me in this, because this exactly waht i am trying to do, thanks

thanks

i finally manage to get the example working, really good macro

If I understand this right, you want to:

the first x values in column A that together sum the value in column B
(that is what your first post says)

or:

all combinations that together sum the value in column B.
Then my question is: where do you want to put this lists? This decides mainly if you want to use macro or not.
I never tried combinations but this should not be too hard if you understand a bit of VBA.

Replies
10
Views
2K
Replies
2
Views
292
Replies
0
Views
160
Replies
3
Views
603
Replies
2
Views
772

1,203,428
Messages
6,055,318
Members
444,780
Latest member
jtfish

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.

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