Create summary without generating total of combinations by each sum

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello, I got a code to By Marcelo Branco, which generate all-possible sets using following layout under this link is superb! The summary below I got generating all combinations with the code and then counting by sum as shown in the Column H:J
https://www.mrexcel.com/forum/excel-questions/1093756-combine-all-products-different-varieties-2.html#post5261054


But I want a separate code, which can make an only summary without generating any combinations as shown in the column H:J with given example data in the range D5:F12
Example data... [TABLE="width: 621"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Min Sum[/TD]
[TD]135[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Max Sum[/TD]
[TD]476[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Total[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]With[/TD]
[TD]Combination[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Price $[/TD]
[TD]Price $[/TD]
[TD]Price $[/TD]
[TD][/TD]
[TD]Sum [/TD]
[TD]6561[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]9[/TD]
[TD]13[/TD]
[TD]78[/TD]
[TD][/TD]
[TD]135[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]23[/TD]
[TD]34[/TD]
[TD]43[/TD]
[TD][/TD]
[TD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[TR]
[TD]16[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]146[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]147[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]18[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]148[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]19[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]149[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]20
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]150[/TD]
[TD]7[/TD]
[/TR]
</tbody>[/TABLE]

Thanks In Advance
Using version 2000
Regards,
Moti
 
Last edited by a moderator:
Try

Code:
Sub aTestV2_Summary()
    Dim pa As Variant, pb As Variant, pc As Variant, pd As Variant
    Dim pe As Variant, pf As Variant, pg As Variant, ph As Variant
    Dim i As Long, j As Long, k As Long, l As Long
    Dim m As Long, n As Long, o As Long, p As Long
    Dim myArr(1 To 8), xSum As Long
    Dim ArrRes() As Variant
    
    pa = Range("D5:F5")
    pb = Range("D6:F6")
    pc = Range("D7:F7")
    pd = Range("D8:F8")
    pe = Range("D9:F9")
    pf = Range("D10:F10")
    pg = Range("D11:F11")
    ph = Range("D12:F12")
    
    ReDim ArrRes(Range("E1").Value To Range("E2").Value, 1 To 2)
    For i = Range("E1").Value To Range("E2").Value
        ArrRes(i, 1) = i
        ArrRes(i, 2) = 0
    Next i
    
    For i = 1 To 3
      For j = 1 To 3
        For k = 1 To 3
          For l = 1 To 3
            For m = 1 To 3
              For n = 1 To 3
                For o = 1 To 3
                  For p = 1 To 3
                    myArr(1) = pa(1, i)
                    myArr(2) = pb(1, j)
                    myArr(3) = pc(1, k)
                    myArr(4) = pd(1, l)
                    myArr(5) = pe(1, m)
                    myArr(6) = pf(1, n)
                    myArr(7) = pg(1, o)
                    myArr(8) = ph(1, p)
                    xSum = WorksheetFunction.Sum(myArr)
                    ArrRes(xSum, 2) = ArrRes(xSum, 2) + 1
                  Next p
                Next o
              Next n
            Next m
          Next l
        Next k
      Next j
    Next i
    Range("H5").Resize(Range("E2").Value - Range("E1").Value + 1, 2) = ArrRes
End Sub

M.
Marcelo Branco, I want to tell you the truth I lost hope because firstly the min & max numbers are variable they don't have the top and bottom in the sequence like 1, 2, 3 and so on. Second complexities were they are distributed in 3 columns and 8 rows. </SPAN></SPAN>

I am very impressed by your coding, code worked like a charm create a summary without generating any combinations as I request absolutely amazing!
</SPAN></SPAN>

Marcelo Branco, I am extremely happy to get a solution and very grateful to you for your time you spent to solving my requirement
</SPAN></SPAN>

:pray: Good Luck
</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Moti :grin:
</SPAN></SPAN>
 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,224,828
Messages
6,181,206
Members
453,022
Latest member
RobertV1609

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top