google-sheetsrandomgoogle-sheets-formula

Generate unique random numbers in Google Sheets


I want to generate in cells A1, B1, C1, D1, random numbers within the range 10 to 30. I have put in these cells the same function =RANDBETWEEN(10;30). However, random numbers sometimes have duplicate values, which I don't want.

So that the random numbers appearing at the same time in these 4 boxes do not overlap, what should I do?


Solution

  • You can create like 10 random numbers, choose the first 4 unique among them:

    =ARRAY_CONSTRAIN(UNIQUE(BYCOL(SEQUENCE(1,10),LAMBDA(r, RANDBETWEEN(10,30))),1),1,4)