Tanner_2004
Well-known Member
- Joined
- Jun 1, 2010
- Messages
- 616
This code works great, but it stops after producing 10 random numbers. Can someone please tell me how to modify so that it produces a random number for every cell within an selected range? Thank you.
Code:
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