Thread: VBA help
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default VBA help

What is Decimals supposed to be (it is not declared anywhere that I can
see)?

--
Rick (MVP - Excel)


"Soccerboy83" wrote in message
...
My question is this, i have a forumula in VBA that reads as follows,


Public Function RandomNumbers(Lowest As Long, Highest As Long)
If IsMissing(Decimals) Or Decimals = 0 Then
Randomize
RandomNumbers = Int((Highest + 1 - Lowest) * Rnd + Lowest)
Else
Randomize
RandomNumbers = Round((Highest - Lowest) * Rnd + Lowest, Decimals)
End If
End Function

However when i try and run the program it is giving me problems. It keeps
telling Highlighting (Decimals) and gives me an compilation error, saying
it
cannot find it in the project or Library. Can someone please help me. or
give me another way of writing the code above to give me a random number,
that does not recalculate every time something changes. Thanks,