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:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
</SPAN>Hello, many hours trying to find a solution of my query, did all possible search within MrExcel found just one code line, adding code line modifying Marcelo Branco code as shown below now it generate only all sum in the column K from min 135 to max 476 but cant find any way to get to get summary only unique sums and count of them as I want in the column H:I without generating all sum in the column K </SPAN></SPAN>

Please help</SPAN></SPAN>
Modified code...</SPAN></SPAN>
Rich (BB 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), lLin As Long
    
    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")
    
    lLin = 4
    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) ' Added New Line
                    
                     lLin = lLin + 1
                    'Range("I" & lLin).Resize(, 8) = myArr 'Changed This Code Line With Below Line
                     
                     Range("K" & lLin).Resize(, 1) = Xsum ' Added New Line
                  Next p
                Next o
              Next n
            Next m
          Next l
        Next k
      Next j
    Next i
    
    'With Range("Q5:Q" & lLin)
        '.Formula = "=SUM(I5:P5)"
        '.Value = .Value
    'End With
    'Optional - sort ascending
    SortResults lLin
End Sub
Sub SortResults(lr As Long)
    Range("K4:I" & lr).Sort key1:=Range("K4"), order1:=xlAscending, Header:=xlYes
End Sub

Result only summary required in the columns H:I</SPAN></SPAN>


Book1
ABCDEFGHIJK
1Min Sum135
2Max Sum476SummaryCount
3UniqueCombinationWith
4Price $Price $Price $Sums6561Sum
5913781351135
62334431361136
7584111370138
85926151381139
91220681391140
102733401401141
113332351412141
121269191424142
131432142
141443142
151453142
161466143
171475143
181487144
191498144
201507144
211517145
2215210145
2315314145
2415410146
2515515146
2615614146
2715715146
2815812146
2915922146
3016019147
3116119147
3216220147
3316322147
3416421147
3516520148
3616628148
3716724148
3816825148
3916921148
4017029148
4117122148
4217226149
4317326149
4417427149
4517521149
4617623149
4717726149
4817820149
4917925149
5018022150
5118122150
5218216150
5318321150
54150
55150
56150
Sheet2


Thanks In Advance</SPAN></SPAN>
Using version 2000</SPAN></SPAN>
Regards, </SPAN></SPAN>
Moti</SPAN></SPAN>
 
Last edited:
Upvote 0
Hello, I found in my archive that the StephenCrump, make a macro which get summary of lottery 6_49 without generating the combinations. I tried to understand the code and make a modification to apply with my requirements to this thread but I felt it is impossible for me.</SPAN></SPAN>

https://www.mrexcel.com/forum/excel...te-lottery-combinations-sums.html#post4586865

</SPAN></SPAN>
Please need your help
</SPAN>
</SPAN>Thank you in advance

Regards,
</SPAN></SPAN>
Moti
</SPAN></SPAN>
 
Last edited:
Upvote 0
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.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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