+ Reply to Thread
Results 1 to 10 of 10

formula to determine how many times can combination of numbers fit into parent number

  1. #1
    Registered User
    Join Date
    11-18-2019
    Location
    Jerusalem
    MS-Off Ver
    365
    Posts
    15

    formula to determine how many times can combination of numbers fit into parent number

    Hello All,

    What I am attempting to is relatively simple to do manually, however I cannot seem to wrap my head around how to do this dynamically in excel.
    I have a parent number in Cell A1 (say: 20) , and then a list of numbers in Column B (say: 4,3,2)

    I would like to create a formula in column C that dynamically tells me how to best fit the combination of the numbers in column B into the number in Cell A1?

    I apologise in advance for not explaining myself clearly enough. I have posted a few examples with explanations below hoping it clarifies what I am attempting to do:

    Screen Shot 2019-11-18 at 17.25.35.png

    Thank you

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: formula to determine how many times can combination of numbers fit into parent number

    Hi and welcome
    have a look at the yellow banner please.

  3. #3
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: formula to determine how many times can combination of numbers fit into parent number

    Do you predict more values in col B? Or just 3?
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  4. #4
    Registered User
    Join Date
    11-18-2019
    Location
    Jerusalem
    MS-Off Ver
    365
    Posts
    15

    Re: formula to determine how many times can combination of numbers fit into parent number

    Hi Kokosek,

    Potentially yes. But I would be happy with an answer that gives me a solution for anything up to 5 values in column B.

    Thanks.

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: formula to determine how many times can combination of numbers fit into parent number

    Please post a sheet as requested. Nobody wants to loose time retyping your data for testing

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: formula to determine how many times can combination of numbers fit into parent number

    Do you already know the algorithm you want to use here and just need help programming that into Excel, or are you needing us to help develop the algorithm (not really an Excel specific question)?

    Off the top of my head, the problem seems similar to subset sum and factorization algorithms -- none of which (off the top of my head) really work as single cell formulas. Off the top of my head, the algorithms that suggest themselves are trial and error algorithms, which, again, don't lend themselves well to single cell formulas.

    My first thought (because it involves the least programming) is to use Solver for something like this. On the surface, it can be fairly simple. A SUMPRODUCT() formula to use as the objective function (=SUMPRODUCT(B1:B3,C1:C3)-A1 because I like to target the value 0), then call Solver and tell it to Set target cell (the cell with the SUMPRODUCT() formula) to a value of 0 by changing C1:C3 Subject to the constraint that C1:C3 are integers and meet whatever your "best combination" criterion is (SUM(C1:C3) is at its minimum?). Or maybe you need to flip that around and find the optimum of your "best combination" criterion by changing C1:C3 subject to the constraint that your SUMPRODUCT() formula is 0. Or maybe it needs to get more complicated than that. I don't know, I haven't thought through it all the way.

    The advantage of using Solver is that most of the programming is already done for us. We just need to figure out objective and constraint functions that will allow Solver's algorithms to reliably find our solution.

    Does that help at all?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  7. #7
    Registered User
    Join Date
    11-18-2019
    Location
    Jerusalem
    MS-Off Ver
    365
    Posts
    15

    Re: formula to determine how many times can combination of numbers fit into parent number

    Hi Pepe le Mokko,

    I am attempting to do so but the add attachment bubble is not opening up.
    I have followed the directions in the yellow bubble at the top of the screen but still not working.

  8. #8
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: formula to determine how many times can combination of numbers fit into parent number

    Terrible formula (I believe should be easier to solve) but seems to be working:

    A
    B
    C
    1
    A B C
    2
    75
    9
    8
    3
    7
    0
    4
    5
    0
    5
    4
    0
    6
    3
    1
    7
    2
    0


    I can't paste formula (firewall find HTML????).

    Check attached file.
    Attached Files Attached Files
    Last edited by KOKOSEK; 11-18-2019 at 12:37 PM.

  9. #9
    Registered User
    Join Date
    11-18-2019
    Location
    Jerusalem
    MS-Off Ver
    365
    Posts
    15

    Re: formula to determine how many times can combination of numbers fit into parent number

    KOKOSEK,

    Wow, works like wonders! Thank you so much.
    I will now attempt to decipher what it is you did so i can understand the formula

    Thanks again

  10. #10
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: formula to determine how many times can combination of numbers fit into parent number

    Happy to help.
    It is not hard to get. Check if its still need to be split and MOD of division is less than smallest divisor from list, so depends of this two different division (inc. MOD multiplying deduction or not).
    If you want to expand list of divisors you have to change parameter here:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 08-28-2017, 07:35 PM
  2. Replies: 7
    Last Post: 01-25-2016, 08:10 AM
  3. Replies: 8
    Last Post: 09-10-2015, 03:43 PM
  4. Replies: 3
    Last Post: 02-07-2014, 03:22 AM
  5. [SOLVED] Determine whether number of positive numbers exceeds number of negative numbers
    By HRBP in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-04-2012, 09:49 PM
  6. Replies: 3
    Last Post: 05-14-2012, 10:22 PM
  7. Replies: 11
    Last Post: 03-10-2011, 08:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1