Random number assignment

zereusz

New Member
Joined
Nov 21, 2018
Messages
10
I have 1 excel problem.

• I have 9 different numbers or letters (from "1 to 9" or "a to i").

• For each number I need to assign 1 number from remaining not assigned numbers (same number can not be assigned to itself for example 1 can not be assigned to 1).

• Second requirement is that each number has to be used only 1 time.

Can anyone help me with excel code? Thanks.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
does it works for you?


Book1
ABC
1A0.6324353
2B0.4832757
3C0.5549636
4D0.6642182
5E0.1162310
6F0.2553118
7G0.608364
8H0.9489711
9I0.5555995
10J0.1698529
Sheet2
Cell Formulas
RangeFormula
B1=RAND()
C1=RANK(B1,$B$1:$B$10)
 
Upvote 0
does it works for you?

ABC
A
B
C
D
E
F
G
H
I
J

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"]0.632435[/TD]
[TD="align: right"]3[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]0.483275[/TD]
[TD="align: right"]7[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]0.554963[/TD]
[TD="align: right"]6[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]0.664218[/TD]
[TD="align: right"]2[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]0.11623[/TD]
[TD="align: right"]10[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"]0.255311[/TD]
[TD="align: right"]8[/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]0.60836[/TD]
[TD="align: right"]4[/TD]

[TD="align: center"]8[/TD]

[TD="align: right"]0.948971[/TD]
[TD="align: right"]1[/TD]

[TD="align: center"]9[/TD]

[TD="align: right"]0.555599[/TD]
[TD="align: right"]5[/TD]

[TD="align: center"]10[/TD]

[TD="align: right"]0.169852[/TD]
[TD="align: right"]9[/TD]

</tbody>
Sheet2

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B1[/TH]
[TD="align: left"]=RAND()[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C1[/TH]
[TD="align: left"]=RANK(B1,$B$1:$B$10)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]


Great it works for me.
Can you shortly explain how?
Thank you very much.
 
Upvote 0
just now I identified that there is possibility to assign same number to same number.

it shouldn't,

fyi, column B produces a set of random numbers between 0 and 1, and Column C ranked them
 
Last edited:
Upvote 0
in case of number 1 (first row) sometimes after refreshing it assigning 1 to 1. anyway it works for my case.
 
Upvote 0
kOKRZq
mR4ofV
 
Upvote 0
I've misread your requirement and unfortunately the solution provided is not a good one
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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