Hello,
I'd like to create a column range with a bunch of random normal variables, and I'd like to control the seed so that I could reproduce the numbers if needed.
All I was able to find online was this post on stackoverflow:
Repeating random variables in VBA - Stack Overflow
Modifying the code to test and meet my needs:
However, the random numbers generated in column 1 and column 3 do not match. Please let me know what I am missing to do this.
I also tried using the macro recorder and using the Data Analysis Tool pak. The code it generated was:
That code seemed really simple, but when I tried to modify it like this:
I get an error message:
"Sorry, we couldn't fine "\\co-file\FolderRedirection$\ckiniry\Desktop\Robert - Rolling Forecast\Test Clean Data with R\Cleaned Data\ATPVBAEN.XLAM". Is it possible it was moved, renamed, or deleted"
After I hit OK, I get the error message:
Run-time error '1004:
Microsoft Excel cannot access the file "\\co-file\FolderRedirection$\ckiniry\Desktop\Robert - Rolling Forecast\Test Clean Data with R\Cleaned Data\ATPVBAEN.XLAM" There are several possible reasons:
-The file name or path does not exist.
-The file is being used by another program.
Any help would be appreciated! Thanks!
-Chris
I'd like to create a column range with a bunch of random normal variables, and I'd like to control the seed so that I could reproduce the numbers if needed.
All I was able to find online was this post on stackoverflow:
Repeating random variables in VBA - Stack Overflow
Modifying the code to test and meet my needs:
Code:
Sub Test()
Dim Mymean As Integer
Dim Mysd As Integer
Mymean = 90
Mysd = 15
Stupid_Step = Rnd(-1)
Randomize 10
With Range(Cells(1, 1), Cells(100, 1))
.FormulaR1C1 = "=NORMINV( RAND(), " & Mymean & ", " & Mysd & ")"
.Value = .Value
End With
Randomize 10
With Range(Cells(1, 3), Cells(100, 3))
.FormulaR1C1 = "=NORMINV( RAND(), " & Mymean & ", " & Mysd & ")"
.Value = .Value
End With
End Sub
However, the random numbers generated in column 1 and column 3 do not match. Please let me know what I am missing to do this.
I also tried using the macro recorder and using the Data Analysis Tool pak. The code it generated was:
Code:
Sub Macro3()
Application.Run "ATPVBAEN.XLAM!Random", ActiveSheet.Range("$A$1"), 1, 100 _
, 2, 1, 90, 15
End Sub
That code seemed really simple, but when I tried to modify it like this:
Code:
Sub Macro3_Modified()
Application.Run "ATPVBAEN.XLAM!Random", ActiveSheet.Range("$C$1"), 1, 100 _
, 2, 1, 90, 15
End Sub
I get an error message:
"Sorry, we couldn't fine "\\co-file\FolderRedirection$\ckiniry\Desktop\Robert - Rolling Forecast\Test Clean Data with R\Cleaned Data\ATPVBAEN.XLAM". Is it possible it was moved, renamed, or deleted"
After I hit OK, I get the error message:
Run-time error '1004:
Microsoft Excel cannot access the file "\\co-file\FolderRedirection$\ckiniry\Desktop\Robert - Rolling Forecast\Test Clean Data with R\Cleaned Data\ATPVBAEN.XLAM" There are several possible reasons:
-The file name or path does not exist.
-The file is being used by another program.
Any help would be appreciated! Thanks!
-Chris