View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Non updatable Unique Random Number

Thanks for the example, Bob. Runs great!
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Bob Phillips" wrote:
I have left Leo's random number generator function alone (although the way
that I am doing it, you could probably remove the need to pass the range
through), and I had to declare RandNum in it as I always use Option
Explicit.

Sub GenerateRandoms()
Dim rng As Range
Dim cell As Range
Dim FirstNum
Dim LastNum

Set rng = Application.InputBox(prompt:="Select range", Type:=8)
If rng Is Nothing Then Exit Sub
FirstNum = InputBox("Provide the starting number")
If FirstNum = "" Then Exit Sub
LastNum = InputBox("Provide the final number")
If LastNum = "" Then Exit Sub

For Each cell In rng
cell.Value = NewRandNum(rng, FirstNum, LastNum)
Next cell

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)