View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Non updatable Unique Random Number

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)

"Max" wrote in message
...
Bob, thanks. Any chance of a sample to work it here for study? Think I'm

not
vba-versed sufficiently to fashion it out <g. Thanks.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Bob Phillips" wrote in message
...
Max,

Set rng = Application.Inputbox("Select range", Type:=8)

allows the selection of a range mid-macro, and a couple more inputboxes
could be added to get the limits, but that sounds like it would be

better
to
throw up a simple form to get the details, easier to control.