Sub Rnd_N_REP()
Dim myrange As Range, rr, cc, pp As Integer
rr = [B2]: cc = [B1]
pp = rr * cc + 1
Range("d3").SpecialCells (xlCellTypeLastCell)
Set myrange = Range("d3", [d1000])
myrange.ClearContents
' myrange.Interior.ColorIndex = xlNone
Set myrange = Range("d3", [d3].Offset(rr - 1, cc - 1))
'myrange.Interior.ColorIndex = 6
Randomize
For i = 0 To pp - 2
rw = i Mod rr + 3
If rr = cc Then cl = Int(i / cc) + 3 Else cl = i Mod cc + 4
10 x = Int(Rnd * pp)
For Each ce In myrange
If ce = x Or x = 0 Then GoTo 10
Next ce
Cells(rw, cl).Value = x
Next i
[d3].Select
End Sub
الأخوة الأفاضل /
أشكركم
لقد توصلت إلى الحل