Private Sub CommandButton1_Click() On Error Resume Next Dim dictRed As Object Dim arrData, arrResult Dim j As Integer, k As Integer Dim strLottery As String Set dictRed = CreateObject("Scripting.Dictionary") arrData = Sheet1.Cells.CurrentRegion If IsEmpty(arrData) Then arrData = Array(Array("", "", "", "", "", "", "", "", "")) ReDim arrResult(1 To 7)100 Randomize Do dictRed.RemoveAll For j = 1 To 7 If j <= 6 Then arrResult(j) = Int(33 * Rnd) + 1 dictRed(arrResult(j)) = "" Else arrResult(j) = Int(16 * Rnd) + 1 End If Next j If dictRed.Count = 6 Then Exit Do Loop strLottery = arrResult(1) & "|" & arrResult(2) & "|" & arrResult(3) & "|" & _ arrResult(4) & "|" & arrResult(5) & "|" & arrResult(6) & "|" & arrResult(7) For k = 2 To UBound(arrData) If UBound(arrData, 2) >= 9 Then If strLottery = arrData(k, 3) & "|" & arrData(k, 4) & "|" & arrData(k, 5) & "|" & _ arrData(k, 6) & "|" & arrData(k, 7) & "|" & arrData(k, 8) & "|" & arrData(k, 9) Then GoTo 100 End If End If Next k Me.Label1.Caption = arrResult(1) Me.Label2.Caption = arrResult(2) Me.Label3.Caption = arrResult(3) Me.Label4.Caption = arrResult(4) Me.Label5.Caption = arrResult(5) Me.Label6.Caption = arrResult(6) Me.Label7.Caption = arrResult(7) Set dictRed = NothingEnd Sub