Can't find "Solver"

B

Bill Allen

I'm writing one of my first macros and I would appreciate some help.

I am trying to automate the Solver add-in. I started by using the macro
recorder which generated the following:

Sub SolveForK()
'
' SolveForK Macro
' Macro recorded 1/29/2005 by Bill Allen, S.E.
'
' Keyboard Shortcut: Ctrl+Shift+K
'
SolverOk SetCell:="$R$5", MaxMinVal:=3, ValueOf:="0", ByChange:="$Q$5"
SolverSolve
End Sub

Question 1:
When I try to execute the code, I get the following error:

With the "SolverOk" highlighted, the error reads:
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

Sub or Function not defined
---------------------------
OK Help
---------------------------

What is wrong with the code? What do I need to fix?

Thanks,

Bill
 
B

Bill Allen

Nevermind. I did it the old fashioned way:
Sub SolveForK()
'
' SolveForK Macro
' Macro recorded 1/29/2005 by Bill Allen, S.E.
'
' Keyboard Shortcut: Ctrl+Shift+K
'
Dim k As Double
Dim Pi As Double
Dim Ga As Double
Dim Gb As Double
Dim Answer As Double

k = 2
Pi = 3.14159
Ga = ActiveCell.Offset(0, 5).Value
Gb = ActiveCell.Offset(0, 6).Value
Do Until Answer > 0
k = k - 0.001
ActiveCell.Offset(0, 16).Value = k
Answer = ActiveCell.Offset(0, 17).Value
Loop

End Sub

I'm sure I'll have more (potentially stupid) questions as I learn VBA.
Please have patience with me.

Regards,

Bill Allen
 
J

Jim Vierra

Don't feel bad - I do that all of the time and I've been doing this for 25
years.
 
T

Tushar Mehta

If you are still tracking responses to your post, check XL VBA help for
any Solver function (such as SolverOK). The 2nd paragraph tells you
why you had the problem.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top