Hi of all.
The file that I attached, it is write in italian language.
The part made in excel is compounded by:
- Five button
- 2 drop down menu
- the central part that you see colored in green is for showing the result of calculation
- the last part that is the result of reaction.
The cells B9 and L9 is used for calculating the number of atoms in each chemical element that made part of reagents (left side of arrow) you can find the results of this, in cells V10; X10; Z10; AB10
The cells AD9 and AO9 is used for calculating the number of atoms in each chemical element that do part of products (right side of arrow) you can find the results of this, in cells V8; X8; Z8; AB8.
Either numbers of atom that compound the reagents and numbers of atom that compound the products are already calculated in the cells above.
What would i like to do?
I would like that the differences between the follow cells is 0, so:
V8 - V10 or V10 - V8 = 0
X8 - X10 or X10 - X8 = 0
Z8 - Z10 or Z10 - Z8 = 0
AB8 - AB10 or AB10 - AB8 = 0
these differents has already been calculated in cells V6, X6, Z6, AB6 then i have calculated the differents between all these cells with a formula in cell T24 (V6+X6+Z6+AB6). This is my target cell in my solver.
This cell must become 0 when i will use the solver.
The constrains are that the cells B9, L9, AD9, AO9 must be greater than 0 and their must be whole numbers (it must be natural numbers).
But it doesn't work.
I also tried to use the solver+VBA code but the result were bad...
So i ask you an help for solving this problem.
It follow below the solver's code.
I call this code when i change something in drop down menù.
I attach my file and i hope that somebody can help me.
Thank you in advance.
Best regards.
The file that I attached, it is write in italian language.
The part made in excel is compounded by:
- Five button
- 2 drop down menu
- the central part that you see colored in green is for showing the result of calculation
- the last part that is the result of reaction.
The cells B9 and L9 is used for calculating the number of atoms in each chemical element that made part of reagents (left side of arrow) you can find the results of this, in cells V10; X10; Z10; AB10
The cells AD9 and AO9 is used for calculating the number of atoms in each chemical element that do part of products (right side of arrow) you can find the results of this, in cells V8; X8; Z8; AB8.
Either numbers of atom that compound the reagents and numbers of atom that compound the products are already calculated in the cells above.
What would i like to do?
I would like that the differences between the follow cells is 0, so:
V8 - V10 or V10 - V8 = 0
X8 - X10 or X10 - X8 = 0
Z8 - Z10 or Z10 - Z8 = 0
AB8 - AB10 or AB10 - AB8 = 0
these differents has already been calculated in cells V6, X6, Z6, AB6 then i have calculated the differents between all these cells with a formula in cell T24 (V6+X6+Z6+AB6). This is my target cell in my solver.
This cell must become 0 when i will use the solver.
The constrains are that the cells B9, L9, AD9, AO9 must be greater than 0 and their must be whole numbers (it must be natural numbers).
But it doesn't work.
I also tried to use the solver+VBA code but the result were bad...
So i ask you an help for solving this problem.
It follow below the solver's code.
Code:
Sub RisDiffZero()
Dim answer As Integer
Application.EnableEvents = False
SolverOk SetCell:="$T$24", MaxMinVal:=3, ValueOf:=0, ByChange:= _
"$B$9,$L$9,$AD$9,$AO$9", Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$B$9", Relation:=1, FormulaText:="Variant"
SolverAdd CellRef:="$L$9", Relation:=1, FormulaText:="Variant"
SolverAdd CellRef:="$AD$9", Relation:=1, FormulaText:="Variant"
SolverAdd CellRef:="$AO$9", Relation:=1, FormulaText:="Variant"
SolverOk SetCell:="$T$24", MaxMinVal:=3, ValueOf:=0, ByChange:= _
"$B$9,$L$9,$AD$9,$AO$9", Engine:=1, EngineDesc:="GRG Nonlinear"
answer = SolverSolve(True, "ShowTrial")
ShowTrial answer
answer = SolverSolve(True, "ShowTrial")
Application.EnableEvents = True
End Sub
I attach my file and i hope that somebody can help me.
Thank you in advance.
Best regards.
Attachments
Last edited by a moderator: