Column A has numbers from 0 to 5. When there is a number greater than 0, I want it to generate that number of random numbers in the columns next to that cell.
For example if A4 = 3, then I want a random numbers in B4,C4 and D4.
I have the following code that works fine in picking up values over 0 and generating a random number between 200 and 300 but I am stuck on how to have it generate more than one. Can anyone point me in the right direction? thank you
Sub RandomNumbers()
Dim i As Integer
Dim j As Integer
Dim lastrow As Integer
lastrow = Range("a1").End(xlDown).Row
For j = 1 To 1
For i = 1 To lastrow
If ThisWorkbook.Sheets("LossFrequency").Cells(i, j).Value > 0 Then
ThisWorkbook.Sheets("LossFrequency").Cells(i, j + 1).Value = Int((300 - 200 + 1) * Rnd + 200)
Else: ThisWorkbook.Sheets("LossFrequency").Cells(i, j + 1).Value = 0
End If
Next i
Next j
End Sub