2

I have made an Excel macro that gives results using solver. After the result is generated it displays a dialogue box to accept the result. As I have 50 solver results in the macro, I have to click OK 50 times.

Is there some tweak in VBA that can be done to automatically click OK or press enter?

2
  • Why not just take the dialogue box out of the code? Just put the solver data into a sheet or something. Why have a box pop up if you just want to automatically clear it? Commented Dec 8, 2014 at 15:16
  • The dialogue box is not generated by me in VBA. It is the result display of excel solver that is implemented in the macro. Please help me with sendkeys command. Commented Dec 13, 2014 at 15:15

4 Answers 4

6

there is an easier way. type this in your code: "solversolve(true)" True makes solver return the results without displaying the Solver Results dialog box

Sign up to request clarification or add additional context in comments.

1 Comment

SendKeys, DisplayAlerts - MSDN says to use SolverSolve ( msdn.microsoft.com/en-us/library/office/ff197237.aspx ). Can even execute another macro rather than display the solution form - why wouldn't you use this method?
2

SendKeys "~" did the work for me. Type this code after the solversolve command and enter gets automatically typed pressing OK and closing the box.

Comments

0

There is a SendKeys command in vba. This allows you to simulate keystrokes.

Comments

-1

Not sure, but try Application.DisplayAlerts

That is, modify your macro:

Application.DisplayAlerts = False    'turns off dialog prompts

your_macro_code_here

Application.DisplayAlerts = True     'turns back on dialog prompts for normal usage

1 Comment

While this is an "answer" it is typically good to give reasons why or sources to back up answers instead of "not sure" guesses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.