I have numbers 1 to 52. I want to generate 6 randon numbers per row in Cols A to F from 1 to 32 on a random basis
My Code generates 10 numbers per row for Col A to F but cannot get it to work correctly
Kindly amend my code
My Code generates 10 numbers per row for Col A to F but cannot get it to work correctly
Kindly amend my code
Code:
Sub GenerateLottoNumbers()
Dim rng As Range
Dim i As Integer, j As Integer
' Set the range where you want to generate the Lotto numbers
Set rng = ThisWorkbook.Sheets("Sheet1").Range("A1:F6") ' Adjust the sheet name and range as needed
' Clear previous data in the range
rng.ClearContents
' Loop through each row in the range
For i = 1 To rng.Rows.Count
' Loop through each column in the row
For j = 1 To 6
' Generate 6 random numbers between 1 and 32
rng.Cells(i, j).Value = Int((32 - 1 + 1) * Rnd + 1)
Next j
Next i
End Sub