Aspiring_Excel_Master
New Member
- Joined
- Oct 15, 2018
- Messages
- 5
Hi
I have a procedure that runs fine when I run it standalone but when I call it from another sub it generates a Type Mismatch Error (run time error 13)
For i = 4 To ColNum
Cells(8, i).Value = Cells(4, i) / Cells(5, i)
'calculate standardized
Sheets("Probit").Cells(11, i).Value = Cells(4, i) * Application.StDev(Range(Cells(15, i), (Cells(LastRow, i)))) / WorksheetFunction.StDev(Range(Cells(15, 2), (Cells(LastRow, 2))))
The first line "(Cells(8, i).Value = Cells(4, i) / Cells(5, i)) "populates fine but the next section with the standard deviation calculation generates the error. i.e debugging takes me to this line:
Sheets("Probit").Cells(11, i).Value = Cells(4, i) * Application.StDev(Range(Cells(15, i), (Cells(LastRow, i)))) / WorksheetFunction.StDev(Range(Cells(15, 2), (Cells(LastRow, 2))))
I've tried different things but cannot get it to run without an error when calling the sub that this bit of code sits in. Any ideas for fixes?
This is how the variables are defined
Dim LastRow As Long, i As Long
Dim ColNum As Integer, obs As Integer, outvariables As Integer
Thanks
AEM
I have a procedure that runs fine when I run it standalone but when I call it from another sub it generates a Type Mismatch Error (run time error 13)
For i = 4 To ColNum
Cells(8, i).Value = Cells(4, i) / Cells(5, i)
'calculate standardized
Sheets("Probit").Cells(11, i).Value = Cells(4, i) * Application.StDev(Range(Cells(15, i), (Cells(LastRow, i)))) / WorksheetFunction.StDev(Range(Cells(15, 2), (Cells(LastRow, 2))))
The first line "(Cells(8, i).Value = Cells(4, i) / Cells(5, i)) "populates fine but the next section with the standard deviation calculation generates the error. i.e debugging takes me to this line:
Sheets("Probit").Cells(11, i).Value = Cells(4, i) * Application.StDev(Range(Cells(15, i), (Cells(LastRow, i)))) / WorksheetFunction.StDev(Range(Cells(15, 2), (Cells(LastRow, 2))))
I've tried different things but cannot get it to run without an error when calling the sub that this bit of code sits in. Any ideas for fixes?
This is how the variables are defined
Dim LastRow As Long, i As Long
Dim ColNum As Integer, obs As Integer, outvariables As Integer
Thanks
AEM