0% found this document useful (0 votes)
17 views

Este Es El Código Del Modulo

This document contains code for an Excel VBA module that runs an optimization solver. It includes subroutines to go to an explanation sheet, set up a user form for input, run the solver on a model worksheet while checking for feasibility, and report or explain the results. If a feasible solution is found, it shows the results on a report worksheet.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Este Es El Código Del Modulo

This document contains code for an Excel VBA module that runs an optimization solver. It includes subroutines to go to an explanation sheet, set up a user form for input, run the solver on a model worksheet while checking for feasibility, and report or explain the results. If a feasible solution is found, it shows the results on a report worksheet.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Este es el código del modulo

Option Explicit
Option Base 1

Sub GoToExplanation()
' Navega de regreso a la hoja Entrada.
Worksheets("Entrada").Activate
Range("F8").Select
End Sub

Sub Setup()
' Obtiene las entradas del usuario.
UserForm1.Show
End Sub

Sub RunSolver()
Application.ScreenUpdating = False

' La hoja Model debe ser visible y debe estar activada para poder correr Solver.

With Worksheets("Modelo")
.Visible = True
.Activate
End With

' Run Solver and check for feasibility. (The code for no feasible solutions is 5.)
' If there is a feasible (hence optimal) solution, show it on the Report sheet.
' Otherwise, report that there are no feasible solutions.
If SolverSolve(UserFinish:=True) <> 5 Then
Worksheets("Reporte").Activate
Else
MsgBox "The Solver couldn't find a solution. Try a different " _
& "set of inputs.", vbExclamation, "No solution"
Call GoToExplanation
End If

' Hide the Model sheet.


Worksheets("Modelo").Visible = False
Application.ScreenUpdating = True
End Sub

You might also like