Rnd Random function is a short code snippet that shows how the useful Rnd Random function VBA macro is working.
For lups = 1 To 10000
Randomize
Color2 = Int((50 * Rnd) + 1)
Row = Int((25 * Rnd) + 1)
Column = Int((25 * Rnd) + 1)
Range("G2").Offset(Row - 1, Column - 1).Interior.ColorIndex = Color2
Next
End Sub
Explanation
The program randomly changes the colorindex in the cells in the excel sheet, the cell is also chosen randomly by selecting a random column and a random row within a predefined range. The random function is actually never totally random as today the human cannot create a random function that is 100% random it is always based on some kind of samples of data and based on the sample numbers are executed. This approach will create loops and making data reappear systematically.Code
Sub Random_FunctionRND()For lups = 1 To 10000
Randomize
Color2 = Int((50 * Rnd) + 1)
Row = Int((25 * Rnd) + 1)
Column = Int((25 * Rnd) + 1)
Range("G2").Offset(Row - 1, Column - 1).Interior.ColorIndex = Color2
Next
End Sub
No comments:
Post a Comment