請教各位大大,小弟正在做模擬驗證,使用亂數產生器產生數據進行模擬驗證,
我在VBA上寫了一段程式產生了巨集按鈕可以在A1:A7產生一週的亂數,可是
我想要在每按一次巨集按鈕就再自動往下產生一週(A8:A14)的亂數該如何
編寫呢?
Sub Project1_Click()
Dim rTar As Range
Randomize
For Each rTar In Range("A1:A7")
rTar = Int((21 - 1) * Rnd + 1) * 0.01
Next
End Sub
Sub test()
Dim r As Range, i As Integer
Set r = Cells(Rows.Count, 1).End(xlUp).Cells
If r.Address = Range("A1").Address Then
Else
Set r = r.Offset(1)
End If
Randomize
For i = 0 To 6
if r.offset(i).row > 52 then exit sub
r.Offset(i).Value = Int((21 - 1) * Rnd + 1) * 0.01
Next i
End Sub