I'm trying to fill a 9X9 tabel, where every row consists of 9 unique numbers between 1 and 9 (like a sudoku tabel). I have completed a code to fill 1 row with 9 unique numbers and it looks like this:
Code
Sub fill()
Const numbrs = 9, sqrs = 9
Dim begin As Range
Set begin = Range("sudoku").CurrentRegion.Offset(1, 1)
ReDim tulem(1 To numbrs)
rnd_n tulem(), numbrs, sqrs
fit tulem(), numbrs, begin
End Sub
Sub fit(sql(), sqlend, place As Range)
For i = 1 To sqlend
place.Cells(1, i) = sql(i)
Next i
End Sub
Sub rnd_n(tulem(), numbrs, sqrs)
Randomize
i = 0
Do While i < numbrs
x = Int(Rnd() * sqrs) + 1
If newnr(x, tulem(), i) Then
i = i + 1
tulem(i) = x
End If
Loop
End Sub
Function newnr(x, sql(), sqlend) As Boolean
newnr = True
For i = 1 To sqlend
If sql(i) = x Then
newnr = False
Exit Function
End If
Next i
End Function
Display More
but how will I be able to fill the rest of the rows (the hole 9x9 table) so that every row has unique numbers and ervery column has unique numbers between 1 and 9?