Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2005

Tip: Looking for answers? Try searching our database.

random number generator

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
manclad - 30 Dec 2005 23:20 GMT
hi there i don't know if this is the right section, however I was
wondering is there some vba or formulae to generate random numbers in a
certain range

I would be very greatful if you can help me

Thanks

Owen

Signature

manclad

Dave Peterson - 30 Dec 2005 23:30 GMT
I like J.E. McGimpsey's =RandInt().

http://www.mcgimpsey.com/excel/udfs/randint.html

> hi there i don't know if this is the right section, however I was
> wondering is there some vba or formulae to generate random numbers in a
[quoted text clipped - 11 lines]
> manclad's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=30016
> View this thread: http://www.excelforum.com/showthread.php?threadid=497074

Signature

Dave Peterson

L. Howard Kittle - 30 Dec 2005 23:30 GMT
=rand() and pull down is the plain answer.  May not meet your need's.

More info, perhaps?

HTH
Regards,
Howard

> hi there i don't know if this is the right section, however I was
> wondering is there some vba or formulae to generate random numbers in a
[quoted text clipped - 5 lines]
>
> Owen
Ken Wright - 31 Dec 2005 00:25 GMT
Try this.  Assign a keyboard combo to it, hit the combo and you will be
prompted for an upper bound, a lower bound and then as to whether you want
decimals or integers.

Sub RandomNumber()
   ubnd = InputBox("Enter Upper Bound")
   lbnd = InputBox("Enter Lower Bound")
   nudp = InputBox("Just hit OK for Integers or type D for decimals")

   Application.ScreenUpdating = False
   Application.Calculation = xlCalculationManual

   On Error GoTo Oops:
   c = Selection.Cells.Count
   x = 1

   If UCase(nudp) = "D" Then
       With Selection
           .ClearContents
           .NumberFormat = "#,##0.00"
       End With
       For Each cell In Selection
           cell.Value = Rnd() * (ubnd - lbnd) + lbnd
           Application.StatusBar = Round(x / c, 2) * 100 & "% Done"
           x = x + 1
       Next cell
   Else
       With Selection
           .ClearContents
           .NumberFormat = "#,##0"
       End With
       For Each cell In Selection
           cell.Value = Int(Rnd() * (ubnd - lbnd + 1) + lbnd)
           Application.StatusBar = Round(x / c, 2) * 100 & "% Done"
           x = x + 1
       Next cell
   End If

   Application.Calculation = xlCalculationAutomatic
   Application.ScreenUpdating = True
   Application.StatusBar = False
Oops:     Exit Sub

End Sub

Signature

Regards
          Ken.......................    Microsoft MVP - Excel
             Sys Spec - Win XP Pro /  XL 97/00/02/03

------------------------------­------------------------------­----------------
It's easier to beg forgiveness than ask permission :-)
------------------------------­------------------------------­----------------

> hi there i don't know if this is the right section, however I was
> wondering is there some vba or formulae to generate random numbers in a
[quoted text clipped - 5 lines]
>
> Owen
tkt_tang@hotmail.com - 31 Dec 2005 03:07 GMT
Say, RandBetween(1, 100) ; more details from the Help File. Regards.
joeu2004@hotmail.com - 31 Dec 2005 11:00 GMT
> I was wondering is there some vba or formulae
> to generate random numbers in a certain range

.... With what distribution?  So far, every respondent has
ass-u-me-d you want a uniform distribution.  I wonder if
you might be interested in another distribution, e.g. a
normal distribution.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.