I have try to run this sub for generation a random sample, but when i try to fix the formula i get only an error message in the celles " Name", in state of gettings the values. Con someone help ?
This is the code , thanks.
Option Explicit
Sub Simulation()
Dim iSize As Integer, pMean As Double, pSD As Double, iBins As String
iBins = 15
iSize = InputBox("New sheet: The size of your sample:", , 100)
pMean = InputBox("New sheet: The mean of yoursample:", , 10)
pSD = InputBox("New sheet: The SD of your sample:", , 0.2)
Set oWS = Worksheets.Add(, ActiveSheet)
Range(Cells(1, 1), Cells(iSize, 1)).Formula = "=Application.WorksheetFunction.NormInv(Rnd(), " & pMean & " , " & pSD & ")"
Range(Cells(1, 1), Cells(iSize, 1)).Formula = Range(Cells(1, 1), Cells(iSize, 1)).Value
Range("E1") = Application.WorksheetFunction.Average(Columns(1))
end sub
Aucun commentaire:
Enregistrer un commentaire