Create summary without generating total of combinations by each sum

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,371
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...
ABCDEFGHI
1Min Sum135
2Max Sum476Total
3WithCombination
4Price $Price $Price $Sum 6561
5913781351
62334431361
7584111370
85926151381
91220681391
102733401401
113332351412
121269191424
131432
141443
151453
161466
171475
181487
191498
20
1507

<tbody>
</tbody>

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

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
</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,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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