Need a macro to arrange lottery draw by sum

serge

Well-known Member
Joined
Oct 8, 2008
Messages
1,446
Office Version
  1. 2007
Platform
  1. Windows
Hi everyone,

I would like to separate all my lottery draw by their sum.

I do not know macro but I know it would do the job, so I'm asking if someone can help me ?

This is for the Mega Millions game 5/56.
My spreadsheet is display like this starting in row : 10.

Column A : Draw number.
Column B : Date.
Column C,D,E,F,G : lottery numbers.
Column I : Sum.

Example : 1. 6/24/2005. 14 43 44 50 56. 207.

The smallest sum for this game would be : 1,2,3,4,5 = 15 and the Highest would be : 52,53,54,55,56 = 270.

Can the macro star arranging them from the Highest to the Smallest sum and each group to be separated by one row, starting in : I10. please. Thank you.
Serge.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
The date column implies that you are going to enter historical data. If that's true, just write a formula to sum each row and sort by that.

If you wanted to list all possible combinations and their sums, it would require 3.8M rows, which Excel does not have.
 
Upvote 0
shg,

Thank you for your reply.

I explain myself wrong, I do not want all possible combinations to be organize by their sum but only my draws history which are at 590 draws so far.

Thank you for the help if anyone can.
Serge.
 
Upvote 0
Hi Serge,

If i've read correctly, then the below should be what you are after...

Code:
Sub arrange()
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("I10:I" & Lastrow).Formula = "=SUM(RC[-6]:RC[-1])"
Cells.Select
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("I10:I" & Lastrow) _
        , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("A10:I" & Lastrow)
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    Range("A1").Select
End Sub

Cheers :)
 
Upvote 0
Thank you Abgar for responding to my post,

Your code works but not exactly how I need it, due to my poor explanation I believe !!!

Your code rearrange all the data from where they are at, and without one row space between each different sum..

What I wanted, is if you can correct it, is to keep the original data where they are in their own column which are A through I, and then the macro will copy and rearrange all those data starting in column :

I10 : Draw number.
J10 : Date.
K10,L10,M10,N10,O10 : Lottery numbers.
P10 : Sum.

With one row space to separate the different sum.

Thank you in advance for helping.

Serge.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

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