+ Reply to Thread
Results 1 to 5 of 5

Combination of numbers that give a single total

  1. #1
    Registered User
    Join Date
    12-04-2014
    Location
    Lagos, Nigeria
    MS-Off Ver
    Excel 2010
    Posts
    6

    Combination of numbers that give a single total

    I am aware this has been discussed overtime and many solutions offered. However, I need something simple that suits my purpose.

    I have a column A with numbers. I have a total in R1C2 and I want the numbers in column A that sum this total to be placed in column C. I expect only one unique solution from the nature of my data which is not too large though I would have iterate through a couple of small data sets.

    I have attempted this solution with solver but I ran into a deadend. Apparenty solver does not update for relations 4,5,6 hence when you constrain with integer or binary it returns decimals. I did check the ignore integer option but still had same results. There seems to be no solution to this online and I have contacted the solver folks and I can't even wait for their response because I have limited time.

    I am hard pressed for time and need this ASAP.

    Can someone help. I would provide more info if need be.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Combination of numbers that give a single total

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    12-04-2014
    Location
    Lagos, Nigeria
    MS-Off Ver
    Excel 2010
    Posts
    6

    Post Re: Combination of numbers that give a single total

    In the attached file, auto format contains trades on 18.18.12. I have already extracted units bolded in column H. Some other trades are broken down into bits.

    I would iterate with units in column H and check for a combination that matches in sheet2 with specific criteria. Like same security and same client.

    I did this with solver that is why the the row immediately below the data has a sumproduct formula. I was supposed to get a 1 or zero but as already stated I had issues around this.

    Now I want the macro to compare the units from auto_format and compare with the respective region(same security, same client) then extract combination in the greened column so I can incorporate them in auto_format.

    hope this clarifies?
    Attached Files Attached Files
    Last edited by Jorgeewa; 12-22-2014 at 08:48 AM.

  4. #4
    Registered User
    Join Date
    12-04-2014
    Location
    Lagos, Nigeria
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Combination of numbers that give a single total

    I forgot to add that I would delete the rows that were identified so that it reduces the number of matching combinations for other trades.

  5. #5
    Registered User
    Join Date
    12-04-2014
    Location
    Lagos, Nigeria
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Combination of numbers that give a single total

    Hi all,

    I got the solution to this problem which is very simple really.

    Instead of Sub solver_binary_constraint()
    '
    ' solver_binary_constraint Macro
    '

    '
    SolverReset
    SolverOptions MaxTime:=0, Iterations:=0, Precision:=0.000001, Convergence:= _
    0.0001, StepThru:=False, Scaling:=False, AssumeNonNeg:=True, Derivatives:=1
    SolverOptions PopulationSize:=100, RandomSeed:=0, MutationRate:=0.075, Multistart _
    :=False, RequireBounds:=True, MaxSubproblems:=0, MaxIntegerSols:=0, _
    IntTolerance:=1, SolveWithout:=False, MaxTimeNoImp:=30

    SolverAdd CellRef:="$E$11:$E$17", Relation:=5, FormulaText:="binary"
    SolverOk SetCell:="$E$18", MaxMinVal:=3, ValueOf:=1226873, ByChange:= _
    "$E$11:$E$17", Engine:=2, EngineDesc:="Simplex LP"

    Solversolve

    End Sub

    Do this and you'd be good to the goods. No decimal number returned. I am elated.

    Sub solver_binary_constraint()
    '
    ' solver_binary_constraint Macro
    '

    '
    SolverReset
    SolverOptions MaxTime:=0, Iterations:=0, Precision:=0.000001, Convergence:= _
    0.0001, StepThru:=False, Scaling:=False, AssumeNonNeg:=True, Derivatives:=1
    SolverOptions PopulationSize:=100, RandomSeed:=0, MutationRate:=0.075, Multistart _
    :=False, RequireBounds:=True, MaxSubproblems:=0, MaxIntegerSols:=0, _
    IntTolerance:=1, SolveWithout:=False, MaxTimeNoImp:=30


    SolverOk SetCell:="$E$18", MaxMinVal:=3, ValueOf:=1226873, ByChange:= _
    "$E$11:$E$17", Engine:=2, EngineDesc:="Simplex LP"
    SolverAdd CellRef:="$E$11:$E$17", Relation:=5, FormulaText:="binary"
    Solversolve

    End Sub

+ 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: 8
    Last Post: 09-10-2015, 03:43 PM
  2. [SOLVED] Count different words and numbers in same range to give total
    By NewbieinNeed3884 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-15-2014, 11:33 PM
  3. HELP adding numbers in HH:MM format to give a general total?
    By BEN HM in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-15-2014, 08:31 AM
  4. Adding multiple numbers in one cell to give a total in another
    By Lunezilla in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-11-2013, 06:12 AM
  5. [SOLVED] Total a Combination of Numbers
    By Erika in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-19-2005, 07:06 PM

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