não tenho "intimidade" com o sover, porem lendo o help para a função solver, no exemplo dado as referencias são passadas como range:
Exemplo do help da Função SoverOK
Worksheets("Sheet1").Activate
SolverReset
SolverOptions precision:=0.001
SolverOK SetCell:=Range("TotalProfit"), _
MaxMinVal:=1, _
ByChange:=Range("C4:E6")
SolverAdd CellRef:=Range("F4:F6"), _
Relation:=1, _
FormulaText:=100
SolverAdd CellRef:=Range("C4:E6"), _
Relation:=3, _
FormulaText:=0
SolverAdd CellRef:=Range("C4:E6"), _
Relation:=4
SolverSolve UserFinish:=False
SolverSave SaveArea:=Range("A33")
Então talvez deva ser utilizada assim:
Sub Solver()
'
' MACRO para utilizar o solver
'
'#########################################################################################
'
' Parâmetros iniciais do solver: Célula destino, Otimização, Intervalo de variáveis, etc..
Dim n As Integer ' Procura a última linha preenchida das variáveis
n = Plan1.Range("B65000").End(xlUp).Row
'Seta os parâmetros iniciais
SolverOK SetCell:=Range("E5"), MaxMinVal:=Range("T4"), ValueOf:=0, ByChange:=Range("E8:E" & n), _
Engine:=2, EngineDesc:="Simplex LP"
'#########################################################################################
'
'Adição das Restrições
Dim h As Integer 'Número de restrições
Dim w As Integer 'Referência para o Loop
Dim q As String 'Referência para localizar célula que deve ser lida
Dim R As Long
h = Plan1.Range("T8") - 1
q = 7 + Plan1.Range("E2")
For w = 1 To h
R = Range("$I$" & q + 1).Value
SolverAdd CellRef:=Range("I" & q), Relation:="" & R, FormulaText:=Range("I" & q + 2)
q = q + 5 + Plan1.Range("E2")
Next w
'##########################################################################################
'
' Finaliza o Solver
SolverSolve True
'
' Define ação e tipo de relatórios
SolverFinish KeepFinal:=1, ReportArray:=1, OutlineReports:=1
End Sub
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 05/10/2012 2:00 pm