View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
R.VENKATARAMAN R.VENKATARAMAN is offline
external usenet poster
 
Posts: 110
Default Trouble with RANDBETWEEN

try something like this
Sub Macro1()
Range("A1").Select
Selection.FormulaR1C1 = "=RANDBETWEEN(1,10)"
Selection.AutoFill Destination:=Range("A1:A16"), Type:=xlFillDefault
Range("A1:A16").Select
End Sub

Tushar Mehta wrote in message
om...
In article ,
says...
How would I go about calculating random numbers using a low and high

number
boundary? I found the RANDBETWEEN function and this is apparently

exactly
what I am looking for, but it does not seem to work in VBA. I am very

new to
VBA and any suggestions would be welcome.

The general rule to generate random integers between a and b, both
inclusive and a < b, is a + Int(Rnd()*(b-a+1))

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions