Skip to main content
10-Marble
May 21, 2024
Solved

Running a MathCAD sheet multiple times with different variable inputs from an excel spreadsheet

  • May 21, 2024
  • 3 replies
  • 4618 views

Hi All, 

We have recently carried out some testing on a system which has generated quite a bit of data on a spreadsheet. 

A calculation was set up to prove the original operation, but since there is now data, our client would it processed. Is there a way to obtain data from an excel spread sheet (one column), put a single value (one cell of the column), process via mathcad calculation and then export the cell to another spread sheet with the result variable desired?

Best answer by Werner_E

Changing all calculations in an already existing worksheet into functions of some input variables can be quite cumbersome and also may impair the readability of the sheet.

 

I made a try with your sheet and stopped where your sheet throws an error anyway (as of F4 being undefined).

See the changes and comments (all highlighted in yellow) in the attached sheet.

 

At the end I show how to read in the data from the Excel sheet, use the functions defined and write back the data to Excel.

Hope it helps - Good luck!

 

3 replies

DJNewman
18-Opal
May 21, 2024
PTC Marketer for Creo and Mathcad. I run their YouTube channels, some Creo campaigns, and all Mathcad campaigns and communications.
10-Marble
May 21, 2024

This is part of the solution, but not the critical part of

 

it. I need to run it by putting in a variable from the spreadsheet where the top red mark is, add it to a vector and process it to get a number at the bottom.

SM_6465178_1-1716254882461.png

So while I can use read excel to get one variable through to get 1 answer, I need it to return to the top, get the next variable and run that one through as well, obviously continuing till I run out of data.

 

DJNewman
18-Opal
May 21, 2024

Can you structure this process with a program with a loop?

(Sounds like you may or may not want it to be recursive too if I'm understanding it right, which I might not be...)

I get the impression you don't want to share the worksheet because it has your client's details on it and you can't make that public, so I can't offer much more specific suggestions.

PTC Marketer for Creo and Mathcad. I run their YouTube channels, some Creo campaigns, and all Mathcad campaigns and communications.
ttokoro
21-Topaz I
21-Topaz I
May 21, 2024

 

Using READEXCEL and WRITEEXCEL I made tetrahedron plots. At first READEXCEL read original tetrahedron 1.xlsx. Then made and write 2.xlsx file. Thereafter program continue the sequence. 

You must make unique names for each excel file and read and write it sequencially. 

 

image.pngimage.pngimage.pngimage.png

t.t.
7-Bedrock
June 24, 2024

This is another thing that could be done with original Mathcad but, apparently can't be done with Prime. You used to be able to insert a Mathcad component within Excel and use an Excel macro to step through the rows reading input data from excel, calculating the result with Mathcad, and returning the result to Excel. I used it when I had multiple (more than 2) input parameters to explore. At least on my setup, Excel lists "Mathcad Worksheet" under Install/ Object, but selecting that brings up the message "Cannot start the source application for this object." I presume that it does not work with Prime.