Iam totally new to the VBA, so I would appreciate your help...
My code so far, first part, where I have made random numbers to the specific range:
Dim i As Long
Randomize
For i = 1 To 20000
Range("A" & i) = Rnd()
Next i
Range("A1") = ("Rand")
ActiveCell.Range("A1:A20000").Select
Sheets("Sheet1").Columns("A").Copy
Sheets("Sheet1").Columns("B").PasteSpecial xlPasteValues
Sheets("Sheet1").Columns("A").Delete
Range("A1") = ("Rand")
MsgBox ("Nagenerovaných 20 000 hodnôt")
Dim alfa As Integer
Dim beta As Integer
Dim a As Long
Range("I2").Value = InputBox("zadaj parameter alfa")
Range("J2").Value = InputBox("zadaj parameter beta")
Range("B2").Select
Range("I2").Value = alfa
Range("J2").Value = beta
For a = 1 To 20000
Range("B" & a) = WorksheetFunction.Gamma_Inv(Rnd(), alfa, beta)
Next a
The first part of the code works fine, but it takes a while to make these random numbers(something about 8 secs. on my laptop), but its annoying. Is there another way how to do it?
The second part does not work. What Iam trying to do is that, instead of Rnd() in gamma function, i want to use the random number I have already generated in previous step, but I dont know how to do that. I Have tried the second part of the code with the rand(), because I wanted to know, if its gonna work, like the code itself, so I could modify it.
Iam stacked here for 2 days, glad for any help.
PS: its a school project, the each part of the code is started by pressing a click button, if you are wondering why I have separated it to the 2 parts.
Thanks
Aucun commentaire:
Enregistrer un commentaire