Oh4fore

Oh4fore

New Member
Joined
Aug 28, 2019
Messages
3
4 Rows and 4 columns using numbers 1 through 16 insert in the 16 numbers in all cells using every combinations should be 5 possible groups


example A1=1 B1=2 C1=3 D1=4
A2=5 B2=6 c2+7 D2=8
A3=9 B3=10 C3=11 D3=12
A4=13 B4=14 C4=15 D4=16
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I need 5 groups of 16 cells with the numbers 1 through 16 inserted in each group. I need #1 to be with every other number only once, . #2 with every other number only once and so on
 
Upvote 0
Like this, for example?

[Table="width:, class:grid"][tr][td="bgcolor:#C0C0C0"][/td][td="bgcolor:#C0C0C0"]
A​
[/td][td="bgcolor:#C0C0C0"]
B​
[/td][td="bgcolor:#C0C0C0"]
C​
[/td][td="bgcolor:#C0C0C0"]
D​
[/td][td="bgcolor:#C0C0C0"]
E​
[/td][td="bgcolor:#C0C0C0"]
F​
[/td][td="bgcolor:#C0C0C0"]
G​
[/td][td="bgcolor:#C0C0C0"]
H​
[/td][td="bgcolor:#C0C0C0"]
I​
[/td][td="bgcolor:#C0C0C0"]
J​
[/td][td="bgcolor:#C0C0C0"]
K​
[/td][td="bgcolor:#C0C0C0"]
L​
[/td][td="bgcolor:#C0C0C0"]
M​
[/td][td="bgcolor:#C0C0C0"]
N​
[/td][td="bgcolor:#C0C0C0"]
O​
[/td][td="bgcolor:#C0C0C0"]
P​
[/td][/tr][tr][td="bgcolor:#C0C0C0"]
1​
[/td][td]
8​
[/td][td]
6​
[/td][td]
5​
[/td][td]
11​
[/td][td]
3​
[/td][td]
10​
[/td][td]
9​
[/td][td]
16​
[/td][td]
7​
[/td][td]
4​
[/td][td]
14​
[/td][td]
2​
[/td][td]
15​
[/td][td]
1​
[/td][td]
13​
[/td][td]
12​
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
2​
[/td][td]
12​
[/td][td]
1​
[/td][td]
7​
[/td][td]
16​
[/td][td]
5​
[/td][td]
9​
[/td][td]
2​
[/td][td]
6​
[/td][td]
8​
[/td][td]
11​
[/td][td]
13​
[/td][td]
3​
[/td][td]
14​
[/td][td]
15​
[/td][td]
10​
[/td][td]
4​
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
3​
[/td][td]
11​
[/td][td]
14​
[/td][td]
12​
[/td][td]
1​
[/td][td]
8​
[/td][td]
3​
[/td][td]
5​
[/td][td]
15​
[/td][td]
4​
[/td][td]
6​
[/td][td]
9​
[/td][td]
7​
[/td][td]
10​
[/td][td]
13​
[/td][td]
2​
[/td][td]
16​
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
4​
[/td][td]
5​
[/td][td]
11​
[/td][td]
2​
[/td][td]
12​
[/td][td]
9​
[/td][td]
14​
[/td][td]
13​
[/td][td]
4​
[/td][td]
3​
[/td][td]
8​
[/td][td]
1​
[/td][td]
10​
[/td][td]
6​
[/td][td]
16​
[/td][td]
15​
[/td][td]
7​
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
5​
[/td][td]
4​
[/td][td]
15​
[/td][td]
8​
[/td][td]
6​
[/td][td]
7​
[/td][td]
2​
[/td][td]
3​
[/td][td]
1​
[/td][td]
12​
[/td][td]
16​
[/td][td]
10​
[/td][td]
5​
[/td][td]
13​
[/td][td]
14​
[/td][td]
9​
[/td][td]
11​
[/td][/tr]
[/table]
 
Upvote 0
I need 5 groups of 16 cells with the numbers 1 through 16 inserted in each group.

For the 5 groups.

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /><col style="width:21.86px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td><td >H</td><td >I</td><td >J</td><td >K</td><td >L</td><td >M</td><td >N</td><td >O</td><td >P</td><td >Q</td><td >R</td><td >S</td><td >T</td><td >U</td><td >V</td><td >W</td><td >X</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td colspan="4" style="background-color:#ffff00; text-align:center; ">GROUP 1</td><td > </td><td colspan="4" style="background-color:#92d050; text-align:center; ">GROUP 2</td><td > </td><td colspan="4" style="background-color:#b8cce4; text-align:center; ">GROUP 3</td><td > </td><td colspan="4" style="background-color:#fcd5b4; text-align:center; ">GROUP 4</td><td > </td><td colspan="4" style="background-color:#b2a1c7; text-align:center; ">GROUP 5</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">3</td><td style="text-align:right; ">10</td><td style="text-align:right; ">6</td><td style="text-align:right; ">2</td><td > </td><td style="text-align:right; ">8</td><td style="text-align:right; ">14</td><td style="text-align:right; ">1</td><td style="text-align:right; ">16</td><td > </td><td style="text-align:right; ">14</td><td style="text-align:right; ">1</td><td style="text-align:right; ">4</td><td style="text-align:right; ">9</td><td > </td><td style="text-align:right; ">9</td><td style="text-align:right; ">6</td><td style="text-align:right; ">3</td><td style="text-align:right; ">14</td><td > </td><td style="text-align:right; ">10</td><td style="text-align:right; ">14</td><td style="text-align:right; ">6</td><td style="text-align:right; ">13</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="text-align:right; ">12</td><td style="text-align:right; ">1</td><td style="text-align:right; ">9</td><td style="text-align:right; ">11</td><td > </td><td style="text-align:right; ">11</td><td style="text-align:right; ">4</td><td style="text-align:right; ">12</td><td style="text-align:right; ">5</td><td > </td><td style="text-align:right; ">12</td><td style="text-align:right; ">11</td><td style="text-align:right; ">3</td><td style="text-align:right; ">13</td><td > </td><td style="text-align:right; ">7</td><td style="text-align:right; ">4</td><td style="text-align:right; ">10</td><td style="text-align:right; ">1</td><td > </td><td style="text-align:right; ">3</td><td style="text-align:right; ">7</td><td style="text-align:right; ">2</td><td style="text-align:right; ">5</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="text-align:right; ">15</td><td style="text-align:right; ">5</td><td style="text-align:right; ">14</td><td style="text-align:right; ">7</td><td > </td><td style="text-align:right; ">2</td><td style="text-align:right; ">15</td><td style="text-align:right; ">7</td><td style="text-align:right; ">3</td><td > </td><td style="text-align:right; ">15</td><td style="text-align:right; ">10</td><td style="text-align:right; ">5</td><td style="text-align:right; ">8</td><td > </td><td style="text-align:right; ">15</td><td style="text-align:right; ">8</td><td style="text-align:right; ">12</td><td style="text-align:right; ">13</td><td > </td><td style="text-align:right; ">16</td><td style="text-align:right; ">12</td><td style="text-align:right; ">11</td><td style="text-align:right; ">1</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="text-align:right; ">16</td><td style="text-align:right; ">4</td><td style="text-align:right; ">8</td><td style="text-align:right; ">13</td><td > </td><td style="text-align:right; ">9</td><td style="text-align:right; ">13</td><td style="text-align:right; ">6</td><td style="text-align:right; ">10</td><td > </td><td style="text-align:right; ">6</td><td style="text-align:right; ">7</td><td style="text-align:right; ">16</td><td style="text-align:right; ">2</td><td > </td><td style="text-align:right; ">2</td><td style="text-align:right; ">11</td><td style="text-align:right; ">16</td><td style="text-align:right; ">5</td><td > </td><td style="text-align:right; ">4</td><td style="text-align:right; ">9</td><td style="text-align:right; ">8</td><td style="text-align:right; ">15</td></tr></table>

Try this:

Code:
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
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top