Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In trying to model an optimization problem, I have successfully
written a macro to iterate through all of the branches of the problem, and copy specified values from the relevant sensitivity reports to a new worksheet (called "Summary"). However, in adding some new constraints to the model, it turns out that the model becomes infeasible for some of the branches. Thus, rather than generating a Sensitivity Report, solver generates a Feasibility Report. My problem: in my VBA code, I reference the Sensitivity Report worksheet by name rather than index number. This causes my macro to bomb out if a particular branch of the problem is infeasible (because there is no appropriate Sensitivity Report to reference). However, if I were to call the sheet by index number, I'd end up (1) not knowing that some of the solutions in "Summary" were infeasible, and that some of the data on that sheet comes from feasibility reports rather than sensitivity reports. My question: is there a way to have my macro behave differently if solver finds that a particular iteration of a problem is infeasible? Relevant code snippet below: SolverSolve (True) efficiency = Cells(27, 11) 'Create Sensitivity report if branch is inefficient If (Round(efficiency, 2) < 1) Then SolverFinish ReportArray:=Array(2) refset = 0 nrefset = 0 'Find branches that constitute reference set of inefficient branch While refset < branches Sheets("Sensitivity Report 1").Select If (Round(Cells(refset + 28, 5), 2) 0) Then Sheets("Summary").Select Cells(k + 27, nrefset + 12) = (refset + 1) nrefset = nrefset + 1 End If refset = refset + 1 Wend Application.DisplayAlerts = False 'Get rid of Sensitivity report, no questions asked... Sheets("Sensitivity Report 1").Delete Application.DisplayAlerts = True Sheets("Branch Analysis G-IN").Select End If My apologies if my code is obtuse or cluttered, this is my first foray into VBA. Thanks for your help! Andrew |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Linear Programming via Excel Solver | Excel Discussion (Misc queries) | |||
Linear Programming(solver ?) | Excel Programming | |||
Excel Solver Programming Error | Excel Programming | |||
SOLVER- programming or not? | Excel Programming | |||
Solver and Excel programming problem | Excel Programming |