I searched for a similar question but couldn't find one..

I want to generate 10 groups out of numbers ranging from 1-60 (including both), with each and every group containing random and non-repeating numbers. How can I do this in excel?


2 Answers 2


How to use it

  1. Open Excel & VBA editor (Alt+F11)
  2. Insert the code below under Sheet1
  3. Go back to Excel and select your desired range to fill with random & non-repeating numbers
  4. Execute the macro (Alt+F8)

Sub randomNumbers()
    Low = Application.InputBox("Enter first valid value", Type:=1)
    High = Application.InputBox("Enter last valid value", Type:=1)
    For Each cell In Selection.Cells
        If WorksheetFunction.CountA(Selection) = (High - Low + 1) Then Exit For
            rndNumber = Int((High - Low + 1) * Rnd() + Low)
        Loop Until Selection.Cells.Find(rndNumber, LookIn:=xlValues, lookat:=xlWhole) Is Nothing
        cell.Value = rndNumber
End Sub

Excel file to proof

I love those small and simple solutions so much

  • Its maybe possible wit Excel functions only: =RANDBETWEEN(1,60) and maybe an array function? But I have no clue how to check for duplicates.
    – nixda
    Jul 3, 2013 at 11:22
  • 1
    – Excellll
    Jul 3, 2013 at 14:02
  • Well, as you already mentioned in the comments, there's a small downside because of MOD. But its a good solution anyway.
    – nixda
    Jul 3, 2013 at 14:37
  • I tried the above mentioned steps but while executing, 9 cells are not filled and and then it crashes..
    – user235376
    Jul 3, 2013 at 16:21
  • I selected 6 x 10 cells (rows or columns) , my first value being 1 and end value being 60. A1 to F10
    – user235376
    Jul 3, 2013 at 17:24

I thought I had an answer, but this was a dead end (but quite fun) and I don't know how to remove it. My need is to do bingo-sheets with random setups.

Make a column A4:A63 with the numbers 1 to 60. Enter a fairly big prime number less than 60 cell B1. For example '47`.

In B2 enter


In rows B4:B63 fill with


This will make a fairly random sequence. B$2 will only shift the sequence.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy