+ Reply to Thread
Results 1 to 3 of 3

Combine value 1 and 2 make row sum=10

  1. #1
    Forum Contributor
    Join Date
    08-06-2006
    Location
    Spain
    MS-Off Ver
    Excel 2010 32Bit
    Posts
    433

    Combine value 1 and 2 make row sum=10

    Using Excel 2010

    Hello,

    I want to know how many combinations could be made if value 1 and 2 split in 14 columns which row sum come up = 10

    Please see the attached workbook with few examples in it.

    Regards,
    Moti
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Combine value 1 and 2 make row sum=10

    try this code

    PHP Code: 
    Option Explicit
    Sub combi
    ()
    Dim n1&, n2&, n3&, n4&, n5&, n6&, n7&, n8&, n9&, n10&, n11&, n12&, n13&, n14&
    Dim k&, res(1 To 10000001 To 14)
    Const 
    TOTA 10 ' Change it
    For n1 = 0 To 2: For n2 = 0 To 2: For n3 = 0 To 2: For n4 = 0 To 2: For n5 = 0 To 2: For n6 = 0 To 2: For n7 = 0 To 2
    For n8 = 0 To 2: For n9 = 0 To 2: For n10 = 0 To 2: For n11 = 0 To 2: For n12 = 0 To 2: For n13 = 0 To 2: For n14 = 0 To 2
        If n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12 + n13 + n14 = TOTA Then
            k = k + 1
            res(k, 1) = n1: res(k, 2) = n2: res(k, 3) = n3: res(k, 4) = n4: res(k, 5) = n5: res(k, 6) = n6: res(k, 7) = n7
            res(k, 8) = n8: res(k, 9) = n9: res(k, 10) = n10: res(k, 11) = n11: res(k, 12) = n12: res(k, 13) = n13: res(k, 14) = n14
        End If
    Next: Next: Next: Next: Next: Next: Next: Next: Next: Next: Next: Next: Next: Next:
    Range("C6:P100000").ClearContents
    Range("C6").Resize(k, 14).Value = res
    End Sub 
    Attached Files Attached Files
    Quang PT

  3. #3
    Forum Contributor
    Join Date
    08-06-2006
    Location
    Spain
    MS-Off Ver
    Excel 2010 32Bit
    Posts
    433

    Re: Combine value 1 and 2 make row sum=10

    Quote Originally Posted by bebo021999 View Post
    try this code
    Thank you bebo021999, for your kind help it work as request and thanks for adding an option I can change desire sum also.

    Good Luck!

    My Best Regards,
    Moti

+ 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. [SOLVED] Combine two codes to make one!
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2021, 07:31 AM
  2. How to make chart in excel combine values with same name
    By smf97 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-01-2020, 06:24 AM
  3. [SOLVED] combine two charts and make empty places
    By littlesonic in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-28-2019, 02:58 AM
  4. Need to combine two spreadsheets to make one
    By mthomisee in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-03-2016, 11:42 AM
  5. How to combine two columns to make phone #s
    By Hook in forum Excel General
    Replies: 3
    Last Post: 02-01-2010, 04:54 PM
  6. [SOLVED] Can I combine 2 rows to make one record?
    By GreenPower in forum Excel General
    Replies: 3
    Last Post: 09-28-2005, 05:05 PM
  7. [SOLVED] how do I combine two forms with different size columns to make on.
    By Morningside in forum Excel General
    Replies: 3
    Last Post: 04-17-2005, 01: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