Introduction#

NaxToCell is an Add-In (an Excel plug-in) that provides useful features for Finite Element Analysis (FEM) in Excel. The main features of NaxToCell are UDFs and Forms.

UDF stands for User Defined Functions. These functions or formulas work just like any other Excel function, but are specifically designed to perform FEM tasks, minimizing duplicated efforts and reducing human errors. The results extracted with NaxToCell are easily traceable, as they are not only numeric values in cells but also formulas with all the arguments written in them.

UDFs enable cascade-like processes and the reusability of custom template spreadsheets, where recalculating results when the input file changes takes just seconds to update entirely.

Basic Usage#

As mentioned before, UDFs are functions added by NaxToCell to the Excel list of functions or formulas. They work just like any other function, with the following main characteristics:

Automatic recalculation (if not disabled) when an input argument is changed.

Input arguments can be explicit values (numbers, text, dates, etc.), references to other cells or ranges of cells in the workbook, or other formulas.

img.png

UDFs in VBA#

The main intended use for UDFs is to write results to cells. However, the results of the formulas can also be used in Visual Basic for Applications (VBA) scripts and macros.

To retrieve the information into a variable in VBA, you need to call the Application.Run or Application.Evaluate methods with the name of the UDF and its input arguments, as shown below:

var = Application.Run("N2CLoadCases", "C:\NAX2CELL\modelOp2.op2", 0, "V")

Here we call the N2CLoadCases UDF in the first argument of the Run method. The following arguments are the ones that would appear in the subcases UDF (file path, option, and orientation). The information will be returned in var, which is a Variant type variable.

var2 = Application.Evaluate( "= N2CLoadCases (""C:\NAX2CELL\modelOp2.op2"",0, ""V"")")

In this case, we call the exact same UDF and arguments but using the Evaluate method. Note that this method takes a single string as an argument. The argument will be the text string that is written in an Excel cell, but with semicolons replaced by commas and double quotes escaped (duplicating them).

An easy script or macro that uses NaxToCell UDFs is shown below. The code is inside a function called extractResults.

Sub extractResults()
    'Declare the string
    Dim strName As String
    strName = "C:\NAXTOCELL\model.op2"
    Var = Application.Run("N2CLoadCases", strName, 0, "V")
EndSub