Pairs of numbers
The following macro gives all the number of occurences of all 1176 pairs of numbers both when considering the 6 main numbers as well as including the bonus number for all draws of a 6/49 lottery.
On page named "Data", in cells A1 to H1 enter titles for Draws number, N1 to N6 and Bonus. In cell K1, enter the number of draws or the formula =MAX(A:A). From line 2, enter the data ine the following order in columns A to H: draw number, N1, N2, N3, N4. N5, N6 and Bonus number.
On a page named "Result", enter titles in A1 to Di; these could be V1 and V2 for value #1 and #2, Freq 6n and Freq 7n for frequency for 6 and 7 numbers.
Enter the following macro in a module and run it to get all occurences of 1176 pairs (1,2 to 48,49) for both 6 and 7 numbers of the lottery. Speed is function of your computer.
Option Explicit
Dim N1 As Integer, N2 As Integer, nCoupleA(49, 49) As Integer, nCoupleB(49, 49) As Integer
Dim nVal As Integer, I As Integer, J As Integer, nNb(7) As Integer, nTmp As Integer
Sub Pair()
Application.ScreenUpdating = False
Sheets("Data").Select
nVal = Range("K1").Value
For N1 = 1 To 49
For N2 = 1 To 49
nCoupleA(N1, N2) = 0
nCoupleB(N1, N2) = 0
Next N2
Next N1
Range("A1").Select
For I = 1 To nVal
ActiveCell.Offset(1, 0).Select
For J = 1 To 7
nNb(J) = ActiveCell.Offset(0, J).Value
Next J
nCoupleA(nNb(1), nNb(2)) = nCoupleA(nNb(1), nNb(2)) + 1
nCoupleA(nNb(1), nNb(3)) = nCoupleA(nNb(1), nNb(3)) + 1
nCoupleA(nNb(1), nNb(4)) = nCoupleA(nNb(1), nNb(4)) + 1
nCoupleA(nNb(1), nNb(5)) = nCoupleA(nNb(1), nNb(5)) + 1
nCoupleA(nNb(1), nNb(6)) = nCoupleA(nNb(1), nNb(6)) + 1
nCoupleA(nNb(2), nNb(3)) = nCoupleA(nNb(2), nNb(3)) + 1
nCoupleA(nNb(2), nNb(4)) = nCoupleA(nNb(2), nNb(4)) + 1
nCoupleA(nNb(2), nNb(5)) = nCoupleA(nNb(2), nNb(5)) + 1
nCoupleA(nNb(2), nNb(6)) = nCoupleA(nNb(2), nNb(6)) + 1
nCoupleA(nNb(3), nNb(4)) = nCoupleA(nNb(3), nNb(4)) + 1
nCoupleA(nNb(3), nNb(5)) = nCoupleA(nNb(3), nNb(5)) + 1
nCoupleA(nNb(3), nNb(6)) = nCoupleA(nNb(3), nNb(6)) + 1
nCoupleA(nNb(4), nNb(5)) = nCoupleA(nNb(4), nNb(5)) + 1
nCoupleA(nNb(4), nNb(6)) = nCoupleA(nNb(4), nNb(6)) + 1
nCoupleA(nNb(5), nNb(6)) = nCoupleA(nNb(5), nNb(6)) + 1
Select Case nNb(7)
Case Is < nNb(1)
nCoupleB(nNb(7), nNb(1)) = nCoupleB(nNb(7), nNb(1)) + 1
nCoupleB(nNb(7), nNb(2)) = nCoupleB(nNb(7), nNb(2)) + 1
nCoupleB(nNb(7), nNb(3)) = nCoupleB(nNb(7), nNb(3)) + 1
nCoupleB(nNb(7), nNb(4)) = nCoupleB(nNb(7), nNb(4)) + 1
nCoupleB(nNb(7), nNb(5)) = nCoupleB(nNb(7), nNb(5)) + 1
nCoupleB(nNb(7), nNb(6)) = nCoupleB(nNb(7), nNb(6)) + 1
Case Is < nNb(2)
nCoupleB(nNb(1), nNb(7)) = nCoupleB(nNb(1), nNb(7)) + 1
nCoupleB(nNb(7), nNb(2)) = nCoupleB(nNb(7), nNb(2)) + 1
nCoupleB(nNb(7), nNb(3)) = nCoupleB(nNb(7), nNb(3)) + 1
nCoupleB(nNb(7), nNb(4)) = nCoupleB(nNb(7), nNb(4)) + 1
nCoupleB(nNb(7), nNb(5)) = nCoupleB(nNb(7), nNb(5)) + 1
nCoupleB(nNb(7), nNb(6)) = nCoupleB(nNb(7), nNb(6)) + 1
Case Is < nNb(3)
nCoupleB(nNb(1), nNb(7)) = nCoupleB(nNb(1), nNb(7)) + 1
nCoupleB(nNb(2), nNb(7)) = nCoupleB(nNb(2), nNb(7)) + 1
nCoupleB(nNb(7), nNb(3)) = nCoupleB(nNb(7), nNb(3)) + 1
nCoupleB(nNb(7), nNb(4)) = nCoupleB(nNb(7), nNb(4)) + 1
nCoupleB(nNb(7), nNb(5)) = nCoupleB(nNb(7), nNb(5)) + 1
nCoupleB(nNb(7), nNb(6)) = nCoupleB(nNb(7), nNb(6)) + 1
Case Is < nNb(4)
nCoupleB(nNb(1), nNb(7)) = nCoupleB(nNb(1), nNb(7)) + 1
nCoupleB(nNb(2), nNb(7)) = nCoupleB(nNb(2), nNb(7)) + 1
nCoupleB(nNb(3), nNb(7)) = nCoupleB(nNb(3), nNb(7)) + 1
nCoupleB(nNb(7), nNb(4)) = nCoupleB(nNb(7), nNb(4)) + 1
nCoupleB(nNb(7), nNb(5)) = nCoupleB(nNb(7), nNb(5)) + 1
nCoupleB(nNb(7), nNb(6)) = nCoupleB(nNb(7), nNb(6)) + 1
Case Is < nNb(5)
nCoupleB(nNb(1), nNb(7)) = nCoupleB(nNb(1), nNb(7)) + 1
nCoupleB(nNb(2), nNb(7)) = nCoupleB(nNb(2), nNb(7)) + 1
nCoupleB(nNb(3), nNb(7)) = nCoupleB(nNb(3), nNb(7)) + 1
nCoupleB(nNb(4), nNb(7)) = nCoupleB(nNb(4), nNb(7)) + 1
nCoupleB(nNb(7), nNb(5)) = nCoupleB(nNb(7), nNb(5)) + 1
nCoupleB(nNb(7), nNb(6)) = nCoupleB(nNb(7), nNb(6)) + 1
Case Is < nNb(6)
nCoupleB(nNb(1), nNb(7)) = nCoupleB(nNb(1), nNb(7)) + 1
nCoupleB(nNb(2), nNb(7)) = nCoupleB(nNb(2), nNb(7)) + 1
nCoupleB(nNb(3), nNb(7)) = nCoupleB(nNb(3), nNb(7)) + 1
nCoupleB(nNb(4), nNb(7)) = nCoupleB(nNb(4), nNb(7)) + 1
nCoupleB(nNb(5), nNb(7)) = nCoupleB(nNb(5), nNb(7)) + 1
nCoupleB(nNb(7), nNb(6)) = nCoupleB(nNb(7), nNb(6)) + 1
Case Is > nNb(6)
nCoupleB(nNb(1), nNb(7)) = nCoupleB(nNb(1), nNb(7)) + 1
nCoupleB(nNb(2), nNb(7)) = nCoupleB(nNb(2), nNb(7)) + 1
nCoupleB(nNb(3), nNb(7)) = nCoupleB(nNb(3), nNb(7)) + 1
nCoupleB(nNb(4), nNb(7)) = nCoupleB(nNb(4), nNb(7)) + 1
nCoupleB(nNb(5), nNb(7)) = nCoupleB(nNb(5), nNb(7)) + 1
nCoupleB(nNb(6), nNb(7)) = nCoupleB(nNb(6), nNb(7)) + 1
End Select
Next I
Range("A1").Select
Sheets("Result").Select
Range("A1").Select
For I = 1 To 48
For J = I + 1 To 49
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = I
ActiveCell.Offset(0, 1).Value = J
ActiveCell.Offset(0, 2).Value = nCoupleA(I, J)
ActiveCell.Offset(0, 3).Value = nCoupleA(I, J) + nCoupleB(I, J)
Next J
Next I
Application.ScreenUpdating = True
Sheets("Result").Select
Range("A1").Select
End Sub