Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
#49133
Pessoal estou tentando fazer um calculo com o solver no VBA e não estou conseguindo executar toda a minha busca, vale ressaltar que comecei agora em programação no VBA.

Vou postar minha planilha aqui e quem puder ir me ajudando a entender o porque não está funcionando fico agradecido.

Ele encontra o valor determinado, mas não deixa eu colocar mais restrições de minimo e máximo valor.

Obs.: peguei parte do código na internet e estou tentando ajustar os valores, caso tenham uma nova ideia podem postar.

ERRO: Ele me trás o valor correto, mas não dentre os valores minimo e máximo.

Sub lsAutoSolver()

SolverReset

Dim i As Long
Dim iTotalLinhas As Long

SolverReset

iTotalLinhas = Cells(Rows.Count, 1).End(xlUp).Row

Range("C7").Select
Selection.Copy

Range("C8:C" & iTotalLinhas).Select
ActiveSheet.Paste

Range("D7").Select
Application.CutCopyMode = False
Selection.Copy

Range("D8:D" & iTotalLinhas).Select
ActiveSheet.Paste

Range("E7").Select
Range("E8:E" & iTotalLinhas).Select

Range("$G$3").Select

SolverOk SetCell:="$G$3", MaxMinVal:=3, ValueOf:=Range("G2").Value, ByChange:="$C$7:$C$" & iTotalLinhas _
, Engine:=1, EngineDesc:="GRG Nonlinear"

SolverAdd CellRef:="$G$4", Relation:=1, formulaText:=3
SolverAdd CellRef:="$C$7:$C$", Relation:=4
SolverAdd CellRef:="$E$7:$E$", Relation:=3, formulaText:=Range("$G$6")
SolverAdd CellRef:="$E$7:$E$", Relation:=1, formulaText:=Range("$G$7")

While i <= iTotalLinhas
SolverAdd CellRef:="$C$" & i, Relation:=5, formulaText:="binary"

i = i + 1
Wend

SolverSolve False

End Sub
Você não está autorizado a ver ou baixar esse anexo.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord