Hi!
I hope you guys can help me to solve the problem I have. I am using MAC office 2011. I am trying to do a likelihood profile. It reads values for the parameter K from a column and uses solver to calculate the value for r that minimizes the objective function. Here is my code:
Sub profile()
For i = 1 To 26
Sheets("Main").Range("B2") = i
k = Sheets("Main").Range("profile_in").Rows(i + 1)
Sheets("Main").Range("k") = k
Sheets("Main").Range("rr") = 0.6
SolverOk SetCell:="b8", MaxMinVal:=2, ValueOf:="0", ByChange:="b3"
SolverSolve UserFinish:=True
likelihood = Sheets("main").Range("scaled")
Sheets("Main").Range("profile_output").Rows(i + 1) = likelihood
Next i
End Sub
My problem is when I do step by step, I need to give solver (SolverSolve) a little time to run it and it will work ok but when I run the macro from Excel, it just solve the first case (i=1) and the remaining cases are not solved. This also happens when I do step by step quickly, any help?
When I used the same code in Windows XP works perfectly, I will appreciate any help, thanks, Jesus
Here is a table with the results:
0.000869504
1.09485E-05
3.34101E-07
4.31503E-08
1.1213E-08
4.28439E-09
2.07281E-09
1.17195E-09
7.38773E-10
5.04123E-10
3.65177E-10
2.77048E-10
2.18027E-10
1.76723E-10
1.46755E-10
1.24345E-10
1.07156E-10
9.36792E-11
8.29135E-11
7.41713E-11
6.69698E-11
6.09617E-11
5.58925E-11
5.15721E-11
4.78566E-11
4.4635E-11
And here is a table with the results with Excel xp:
0.000908182
0.005277419
0.025427526
0.095879037
0.271093711
0.562858248
0.861658306
0.998956855
0.915035585
0.695615175
0.460627264
0.277281031
0.15711879
0.086091158
0.046529477
0.025156593
0.013737611
0.007625153
0.004318797
0.002501572
0.001483347
0.000900627
0.000559728
0.000355833
0.000231188
0.000153355
I hope you guys can help me to solve the problem I have. I am using MAC office 2011. I am trying to do a likelihood profile. It reads values for the parameter K from a column and uses solver to calculate the value for r that minimizes the objective function. Here is my code:
Sub profile()
For i = 1 To 26
Sheets("Main").Range("B2") = i
k = Sheets("Main").Range("profile_in").Rows(i + 1)
Sheets("Main").Range("k") = k
Sheets("Main").Range("rr") = 0.6
SolverOk SetCell:="b8", MaxMinVal:=2, ValueOf:="0", ByChange:="b3"
SolverSolve UserFinish:=True
likelihood = Sheets("main").Range("scaled")
Sheets("Main").Range("profile_output").Rows(i + 1) = likelihood
Next i
End Sub
My problem is when I do step by step, I need to give solver (SolverSolve) a little time to run it and it will work ok but when I run the macro from Excel, it just solve the first case (i=1) and the remaining cases are not solved. This also happens when I do step by step quickly, any help?
When I used the same code in Windows XP works perfectly, I will appreciate any help, thanks, Jesus
Here is a table with the results:
0.000869504
1.09485E-05
3.34101E-07
4.31503E-08
1.1213E-08
4.28439E-09
2.07281E-09
1.17195E-09
7.38773E-10
5.04123E-10
3.65177E-10
2.77048E-10
2.18027E-10
1.76723E-10
1.46755E-10
1.24345E-10
1.07156E-10
9.36792E-11
8.29135E-11
7.41713E-11
6.69698E-11
6.09617E-11
5.58925E-11
5.15721E-11
4.78566E-11
4.4635E-11
And here is a table with the results with Excel xp:
0.000908182
0.005277419
0.025427526
0.095879037
0.271093711
0.562858248
0.861658306
0.998956855
0.915035585
0.695615175
0.460627264
0.277281031
0.15711879
0.086091158
0.046529477
0.025156593
0.013737611
0.007625153
0.004318797
0.002501572
0.001483347
0.000900627
0.000559728
0.000355833
0.000231188
0.000153355