Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA Solver Compile Error: Sub or Function not defined

I am using office 365 for Mac, with version number 15.32.

I repeatedly get the "compile error: sub or function not defined" when I try to run the macro that is trying to implement a solver function, which was a previously recorded macro (so I know it is correct). The error highlights the "SolverOk" part of the code.

I understand that this often occurs when the reference to Solver.xlam is not present, however I have no idea how to do this on the Mac if this is truly the issue. Attached is a screenshot of what I am trying to achieve. Does the Solver.xlam thing on the left indicates that it is there? If so, do you have any idea what the problem is?

Screenshot of available references

Screenshot of error + VBA code

like image 640
Zayd Husseini-Eyre Avatar asked Mar 28 '26 23:03

Zayd Husseini-Eyre


1 Answers

Open File/Options/Add-Ins

On the page with the add ins, click on the bottom "Manage Excel Add-Ins" .. "Go..." and look for SOLVER related Add-ins there.

Once these are activated, return to VBA (Alt-F11) and then the "SOLVER" option should be available in Tools/References, where you want to Add it.

like image 107
SLWS Avatar answered Mar 31 '26 09:03

SLWS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!