VBA Randomize Statement

Randomize Description

Used to change the seed value used by the random number generator for the Rnd function.

Simple Randomize Examples

Sub Randomize_Example()
    Dim randomValue
    Randomize
    
    randomValue = Rnd
End Sub

Randomize Syntax

In the VBA Editor, you can type  “Randomize(” to see the syntax for the Randomize statement:

The Randomize statement contains an argument:

Number: [Optional] It is a numeric “seed” that will be used by the Rnd function to generate a random number.