Sub test()
Dim anArray() As Long
Dim oneCell As Range, i As Long
ReDim anArray(1 To 42)
anArray(1) = 0
For i = 2 To 42: anArray(i) = (anArray(i - 1) + 1) Mod 14: Next i
With Range("A1:A42")
.Value = Application.Transpose(anArray)
.Offset(0, 5).FormulaR1C1 = "=rc1=rc2"
.Offset(0, 6).FormulaR1C1 = "=rc2=rc3"
.Offset(0, 7).FormulaR1C1 = "=rc1=rc3"
.Offset(0, 8).Cells(1, 1).Formula = "=or(" & .Offset(0, 5).Address(, , , True) & ")"
.Offset(0, 8).Cells(2, 1).Formula = "=or(" & .Offset(0, 5).Resize(, 3).Address(, , , True) & ")"
Do Until .Offset(0, 8).Cells(1, 1).Value = False
RandomizeArray anArray
.Offset(0, 1).Value = Application.Transpose(anArray)
Loop
Do Until .Offset(0, 8).Cells(2, 1).Value = False
RandomizeArray anArray
.Offset(0, 2).Value = Application.Transpose(anArray)
Loop
With .Offset(0, 5)
.Resize(, 4).ClearContents
.Formula = "=RAND()"
End With
.Resize(, 6).Sort key1:=.Offset(0, 5), order1:=xlAscending
.Offset(0, 5).ClearContents
For Each oneCell In .Resize(, 3)
oneCell.Value = oneCell.Value + 15
Next oneCell
End With
End Sub
Sub RandomizeArray(ByRef myArray As Variant)
Dim i As Long, randIndex As Long
Dim temp As Variant
Dim Low As Long, High As Long
Low = LBound(myArray): High = UBound(myArray)
For i = Low To High
randIndex = WorksheetFunction.RandBetween(Low, High)
temp = myArray(i)
myArray(i) = myArray(randIndex)
myArray(randIndex) = temp
Next i
End Sub