Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Conditionally reference another worksheet


Conditionally reference another worksheet

My mathcad worksheet performs various calculations and references another mathcad worksheet that contains various fluid properties. I have several worksheets of properties each for a different fluids and I would like to be able to easily switch which file is being referenced depending on which fluid I am interested in without having to delete the reference and insert a new one.  


In my main worksheet with all of the calculations I would like a variable that tells the rest of the worksheet which file to reference. 


Fluid = "Fluid 1"

Calculations use properties of "Fluid 1" 




I do not know a way to conditionally reference a worksheet so will be looking at the answers here.


I do know how to get round your problem.


You can use one worksheet with each property value listed in a matrix.

Each column of the matrix is one property.  Each row of the matrix is one fluid.

You can keep the properties in a text file to easily maintain all the values.


Headers form the first row and origin is set at default value of zero.  row 1 is first fluid with properties in the proper column..


The enclosed shows how to keep the reference as a text file and how to reference for each property.



21-Topaz II


In the main file, add all the references. Then for each fluid you can use a radio button (or button). All the radio buttons will be associated with the same integer variable, for example "flu", so that when you choose a radio button (see example image ), flu will take an integer value and automatically provide the values or other of the chosen fluid.

Buttons as keys:


to the button 1 is associated flu=0, and so on.


where the functions g1, g2, g3, ... are defined in a reference file.

The variables and constants defined in the references cannot be redefined elsewhere otherwise there is a risk of a crash and the loss of the file.



A radio button or dropdown sounds like one method to address the problem.  You may want to read the data in from excel.  Nesting the data would allow for all the fluid types to be available.  Develop a naming convention, which all selection of the fluid of interest.


Good luck.

Top Tags