A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | |
1 | 8 | 6 | 5 | 11 | 3 | 10 | 9 | 16 | 7 | 4 | 14 | 2 | 15 | 1 | 13 | 12 |
2 | 12 | 1 | 7 | 16 | 5 | 9 | 2 | 6 | 8 | 11 | 13 | 3 | 14 | 15 | 10 | 4 |
3 | 11 | 14 | 12 | 1 | 8 | 3 | 5 | 15 | 4 | 6 | 9 | 7 | 10 | 13 | 2 | 16 |
4 | 5 | 11 | 2 | 12 | 9 | 14 | 13 | 4 | 3 | 8 | 1 | 10 | 6 | 16 | 15 | 7 |
5 | 4 | 15 | 8 | 6 | 7 | 2 | 3 | 1 | 12 | 16 | 10 | 5 | 13 | 14 | 9 | 11 |
I need 5 groups of 16 cells with the numbers 1 through 16 inserted in each group.
Sub Groups5()
Dim dict As Object, i As Long, x As Long, y As Long, j As Long
Set dict = CreateObject("scripting.dictionary")
For i = 1 To 16
dict(i) = i
Next
For j = 1 To 5
For i = 1 To 16
x = WorksheetFunction.RandBetween(1, 16)
y = dict(x)
dict(x) = dict(i)
dict(i) = y
Next
i = 1
For Each c In Cells(2, ((j - 1) * 5) + 1).Resize(4, 4)
c.Value = dict(i)
i = i + 1
Next
Next
End Sub