Open Solver Dialog in Excel via VBA

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Open Solver Dialog in Excel via VBA

Post by Rudi »

Hi,

In Excel 2010, how does one write VBA script to activate the solver dialog for the current workbook? This action does not record.

TX
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 79365
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Open Solver Dialog in Excel via VBA

Post by HansV »

Make sure that you set a reference to Solver in Tools | References... in the Visual Basic Editor:
x160.png
You can then use the Solver in VBA.
Reference: Using the Solver VBA Functions.
The individual articles contain examples.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 79365
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Open Solver Dialog in Excel via VBA

Post by HansV »

Oops, sorry, I see that I didn't read your question carefully enough. You want to open the Solver dialog using code, but I have no idea how to do that.
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Open Solver Dialog in Excel via VBA

Post by Rudi »

Thanks for the replies. I have not found anything else on the web that reveals how to access the dialog. Since it's an addin, I don't think its possible. As you state...one can only access the Solver Functions. So code calculates the result internally without the need to show the dialog. One must obviously pass ranges/variables to the Solver functions directly.

TX.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

Becks
2StarLounger
Posts: 196
Joined: 31 Mar 2011, 03:41
Location: Perth, Western Australia

Re: Open Solver Dialog in Excel via VBA

Post by Becks »

For Excel 2007 and earlier, you could use
SOLVER.Solver1.Main

to call the dialog box


Kevin

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Open Solver Dialog in Excel via VBA

Post by agibsonsw »

Becks wrote:For Excel 2007 and earlier, you could use
SOLVER.Solver1.Main

to call the dialog box

Kevin
I'm guessing here but I assume if the dialog is shown and the user clicks Solve there might not be a way to trap this event? That is, it just uses the Solver feature and we are not able to achieve anything with our Solver code. So we can either create our own UserForm version of the Solver dialog, or read necessary details/arguments from a worksheet.

But I may be wrong..? Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.