Forum Discussion
Exporting mathematical model in Excel into a script
Dear Community:
I have been using Excel for modelling Chemical Process Engineering since a while ago.
I find it convenient, as it is visual, easily portable and easily accessible.
I was wondering if there is a way to export a mathematical model into some sort off a script, that contains the equation (starting parameters, intermediates, relationship among cells...).
I often create models, carefully naming the variables, and I see potential into exporting it to another more powerful computational tool (say Python, GAMS....).
I came to know about OpenSolver.xlam, but I think there is an issue with Excel´s natives circular references.
Thank you in advance.
I hope this email finds you well.
- Formula from Excel to text file is possible to be exported/copied using VBA macro. VBA works like other programming languages,, has enough capacity also. You need to work in either way ,, read value from sheet or input through User Form,,, ultimately it needs values to be calculated.
9 Replies
- Rajesh_SinhaIron Contributor
First let me tell you that SOLVER finds an optimal value either maximum or minimum, for formula called the objective cell,, subject to constraints, on the values of other formula cells on a worksheet.
In your case solver hardly works,,, Coz for the Vapor & Mass are independent values (what I found in the Example WB).
If you can handle VBA then I may suggest you method to use Excel formula with VBA code,,, another possibility is using the recently launched LAMBDA,, provides a way to create a custom function, helps to use with Math/Physics base equation in Excel.
- Enrique_Garcia_FrancoCopper Contributor
Rajesh:
Thank you for your answer.
Indeed, I could try solving it in Excel.
The goal is to make the solver value minimal (tending to zero).
However, my goal is to export the equations into a script.
mass = vapor + liquid
Vapor/MW * R * T = P * V_vapor
...
Do you have any comments with these regards?
I would appreciate it.
Have a good day.
Thank you.- Rajesh_SinhaIron ContributorSince Excel uses only cell reference then either you may use cell references or NAME assigned to the cell while using the Formula.
And in case of Excel VBA macro R, T & P should be Variables.
- Rajesh_SinhaIron ContributorIf possible the share some sample data with us along with a few formula you have tried so far,,, & expected output ,, as TABLE & GRAPH/DASHBOARD,,, EXCEL VBA can be used to execute formula on the data in Sheets !!
- Enrique_Garcia_FrancoCopper Contributor
Sorry for my late reply.
Here follows an example on what I meant.
My goal would be to export this simple model into a text script.
Thank you.
Regards.