How to use it
- Open Excel & VBA editor (Alt+F11)
- Insert the code below under
Sheet1
- Go back to Excel and select your desired range to fill with random & non-repeating numbers
- 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) Selection.Clear For Each cell In Selection.Cells If WorksheetFunction.CountA(Selection) = (High - Low + 1) Then Exit For Do rndNumber = Int((High - Low + 1) * Rnd() + Low) Loop Until Selection.Cells.Find(rndNumber, LookIn:=xlValues, lookat:=xlWhole) Is Nothing cell.Value = rndNumber Next End Sub
I love those small and simple solutions so much