Number Grouping

I used to keep the lotto numbers in 2 groups i.e hot & cold. in a spreadsheet.
Each hot & cold contains 50 groups of nos (A1:C50,D1:F50).

Is there anyone know how to write a VBA module to join these two ranges and produce them into a 50x50=2500 rows of numbers (A1:F2500) in a new sheet let says Sheet2?

From there I will filter them out under low & high.

Thanks
Michael
 

GillesD

Member
Number grouping

I am not sure if this is exactly what you want but try the macro listed below and you should get 2500 combinations with 3 numbers in the LOW group and 3 numbers in the HIGH group.

It assumes the data is on Sheet1 (A1:C50 and D1:F50) and results will be posted on Sheet2 in the range A1:F2500.

Option Explicit
Dim I As Integer, J As Integer
Dim nLow(50, 3) As Integer, nHigh(50, 3) As Integer
Sub MixLH()
Application.ScreenUpdating = False
Sheets("Sheet1").Select
Range("A1").Select
I = 1
Do While ActiveCell.Value <> ""
nLow(I, 1) = ActiveCell.Offset(0, 0).Value
nLow(I, 2) = ActiveCell.Offset(0, 1).Value
nLow(I, 3) = ActiveCell.Offset(0, 2).Value
nHigh(I, 1) = ActiveCell.Offset(0, 3).Value
nHigh(I, 2) = ActiveCell.Offset(0, 4).Value
nHigh(I, 3) = ActiveCell.Offset(0, 5).Value
I = I + 1
ActiveCell.Offset(1, 0).Select
Loop
Range("A1").Select
Sheets("Sheet2").Select
Range("A1").Select
For I = 1 To 50
For J = 1 To 50
ActiveCell.Offset(0, 0).Value = nLow(I, 1)
ActiveCell.Offset(0, 1).Value = nLow(I, 2)
ActiveCell.Offset(0, 2).Value = nLow(I, 3)
ActiveCell.Offset(0, 3).Value = nHigh(J, 1)
ActiveCell.Offset(0, 4).Value = nHigh(J, 2)
ActiveCell.Offset(0, 5).Value = nHigh(J, 3)
ActiveCell.Offset(1, 0).Select
Next J
Next I
Range("A1").Select
Application.ScreenUpdating = True
End Sub
 

Sidebar

Top