Description:
The RND function in MS excel returns the random number generated between two specified ranges.
Format:
As VBA Function : Int((Max – Min + 1) * Rnd + Min)
Arguments:
- Max and Min
- Mandatory
- Type: Numbers
- Random number gets generated between these two numbers (Max – the highest value the random number can be. Min – The smallest value the random number can be)
Example:
Function getRnd() Dim Max Dim Min Max = 100 Min = 200 strResult = "The Random number between " & Max & " And " & Min & " is " & Int((Max - Min + 1) * Rnd + Min) & vbCrLf strResult = strResult & "The Random number between " & Max & " And " & Min & " is " & Int((Max - Min + 1) * Rnd + Min) MsgBox strResult End Function