PDA

View Full Version : VBA To Combine A Combination of Values To Get One Target Value



bilbo85
09-12-2017, 04:13 PM
Hi,

I have a random amount in cell A1 (e.g. 50,000) and a list of invoice numbers in column B and their corresponding amounts in column C.

I am after some VBA that can identify and list all possible combinations of invoices that total the target amount of 50,000.

Any idea how to do this please?

Thanks in advance.

mdmackillop
09-13-2017, 01:20 AM
How big is your list? Is there a maximum number of invoices to be combined (preferable)?

bilbo85
09-13-2017, 09:20 AM
It varies but I would say it would be no more than 50 invoices.

mdmackillop
09-13-2017, 09:33 AM
There were 2 questions.

bilbo85
09-13-2017, 10:08 AM
No, there is no maximum.

mdmackillop
09-13-2017, 12:14 PM
Sorry, 1.125 x 10^15 from 50 items is too much for my PC.

bilbo85
09-13-2017, 01:12 PM
I actually just found some code that works quite well but like you say it seems to timeout for more than about 20 invoices. Not to worry, thanks for your time anyway.