I would like the Item column of the Output Table (highlighted in GREEN) to return the value from the Item column in the Reference Table, where the corresponding row in the Rand column has a value of ‘1’.
The Rand column automatically generates random numbers from 1 to 4 in the rows where it matches the criteria from the Input Table.
The problem is at the minute, the random numbers are generated independent of each other and so I don’t get consecutive random numbers from 1 to 4 with each number being unique. It might randomly generate 2,2,3,4 for example, instead of 4,1,3,2 for example.
Is it possible to create a formula that can randomly generate each row with a unique random number from 1 to 4? I assume this might require some VB Code.
Can anyone help, Thanks. Dan
The Rand column automatically generates random numbers from 1 to 4 in the rows where it matches the criteria from the Input Table.
The problem is at the minute, the random numbers are generated independent of each other and so I don’t get consecutive random numbers from 1 to 4 with each number being unique. It might randomly generate 2,2,3,4 for example, instead of 4,1,3,2 for example.
Is it possible to create a formula that can randomly generate each row with a unique random number from 1 to 4? I assume this might require some VB Code.
Can anyone help, Thanks. Dan
EXCEL POST_RandomNumGen_001.xlsx | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | |||
1 | ||||||||||||||||
2 | INPUT TABLE | OUTPUT TABLE | ||||||||||||||
3 | Cat. | STR | Cat. | Lev. | Loc. | Type | Item | |||||||||
4 | Lev. | 2 | STR | 2 | H | U2 | #N/A | |||||||||
5 | Loc. | H | ||||||||||||||
6 | Type | U2 | ||||||||||||||
7 | Count | 4 | ||||||||||||||
8 | ||||||||||||||||
9 | REFERENCE TABLE | |||||||||||||||
10 | Loc. | |||||||||||||||
11 | Cat. | Lev. | H | F | Type | Rand | Item | |||||||||
12 | STR | 1 | F | U1 | - | Item 1 | ||||||||||
13 | STR | 2 | F | U1 | - | Item 2 | ||||||||||
14 | STR | 2 | H | F | U2 | 3 | Item 3 | |||||||||
15 | STR | 3 | H | F | U2 | - | Item 4 | |||||||||
16 | STR | 2 | H | F | U2 | 3 | Item 5 | |||||||||
17 | STR | 4 | H | F | U2 | - | Item 6 | |||||||||
18 | STR | 2 | H | F | U2 | 2 | Item 7 | |||||||||
19 | STR | 3 | H | F | U2 | - | Item 8 | |||||||||
20 | STR | 2 | H | F | U3 | - | Item 9 | |||||||||
21 | STR | 2 | H | F | U3 | - | Item 10 | |||||||||
22 | STR | 1 | H | F | U3 | - | Item 11 | |||||||||
23 | STR | 2 | H | F | U3 | - | Item 12 | |||||||||
24 | STR | 1 | H | F | U3 | - | Item 13 | |||||||||
25 | STR | 2 | H | U4 | - | Item 14 | ||||||||||
26 | STR | 2 | H | F | U4 | - | Item 15 | |||||||||
27 | STR | 2 | H | F | U4 | - | Item 16 | |||||||||
28 | STR | 2 | H | F | U4 | - | Item 17 | |||||||||
29 | STR | 2 | H | F | U4 | - | Item 18 | |||||||||
30 | STR | 2 | H | F | U4 | - | Item 19 | |||||||||
31 | STR | 1 | H | F | U4 | - | Item 20 | |||||||||
32 | STR | 1 | H | F | U4 | - | Item 21 | |||||||||
33 | STR | 1 | H | U2 | - | Item 22 | ||||||||||
34 | STR | 1 | H | U2 | - | Item 23 | ||||||||||
35 | STR | 2 | H | U2 | 2 | Item 24 | ||||||||||
36 | ||||||||||||||||
Sheet1 (2) |
Cell Formulas | ||
---|---|---|
Range | Formula | |
N4 | N4 | =INDEX(Table13[Item],MATCH(1,Table13[Rand],0)) |
G7 | G7 | =COUNTIFS($B12:$B35,G3,$C12:$C35,G4,$D12:$D35,G5,$F12:$F35,G6) |
G12:G35 | G12 | =IF(AND($B12=G$3, $C12=G$4,$D12=G$5,$F12=G$6), RANDBETWEEN(1,G$7), "-") |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
J4 | List | =CAT |
K4 | List | =LEV |
L4 | List | =LOC |
G3 | List | =CAT |
G4 | List | =LEV |
G5 | List | =LOC |
G6 | List | =TYPE |