Forum Discussion
No duplicate cells.
- Apr 08, 2024
One approach is to generate more numbers than needed, remove dupes, and take the first 1000.
=LET(numbers, RANDARRAY(4000, , 1000, 9999, 1), TAKE(UNIQUE(numbers), 1000))
Randarray generates 4,000 numbers betweeen 1000-9999. The 1 is to return whole numbers with no decimals.
First of all, I'm pretty sure that using RANDBETWEEN, with 1 and 1,000 as the lower and upper limits, will NOT generate for you one thousand unique numbers. I just tried it with only 500 entries, and it came up with 388. And that number can change. One of the features of RANDBETWEEN (you can read about it using the hyperlinked word there) is that it's what's called a "volatile" function, meaning it gets recalculated every time you do any other change in the spreadsheet. I.e., any number assigned would change unless you go through a process you can read about via that link to freeze whatever is assigned.
Why use RANDBETWEEN in the first place, one might ask? Why not number them sequentially, perhaps creating an ID that uses sequential numbers (you can begin anywhere) plus, say, the person's initials?
- anbarnes3Apr 08, 2024Copper ContributorI am not looking for numbers in chronological order. Random 4 digits number, almost like a pin.