SOLVER THAT CALL DLL SUB!

P

Pino

Hi
I would use the solver in order to find a value such that a cell=0
(it A3) . This cells is the difference between A1 and A2
IE

a1=4
a2= output of sub of a void in c++ . This sub has as input b1
a3=a1-a2

Changing b1 that is an input of the dll.

I should set a3=0 changing b1 but I need to recalculate every time the
sub (output of dll)
I tried with something (surely wrong) with worksheet change.
If it runs ( often the event doesnt not trigger even if the event
option is set =true)
but I have an runtime error ( maybe 467 ot 497 I dont remember!)
The dll is stable enough and array are passed as safearray.
Any idea?

ths in advance

G.
 
T

Tushar Mehta

Replace the 'sub' in the DLL with a 'function' (i.e., return the desired
value as the value of the function) and treat this function as a User
Defined Function (UDF). This will make it part of the Excel calculation
chain and Excel will know when and how to recalculate the UDF.

Solver assumes it is in complete control of the worksheet and having event
driven routines make changes *may* not -- I am not sure -- play well with
Solver.

I've learnt the hard way to not mess with the worksheet while Solver is
doing its thing.

--
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