Search code examples
excelexcel-formulacatiavba

use excel formulas through VBA in CATIA


I need your help in using CATIA correctly.

I'm currently tasked with creating a "support" Part for a Mould where a capscrew must be inserted (regardless of its length) a maximum of 15mm. The length of the inserted capscrew depends on a plate that is located above the support part. In Excel I have created several formulas that determine which capscrew must be used but I do not know how to use the excel formulas in VBA. Is there any way to use excel formulas or even spreadsheets in VBA?

'declaration of X as "Height of Plate 9"
Dim X As Integer
X = length1.Value

'declaration of Y as the result for the optimal length of the CapScrew to be used
Dim Y As Integer
Y = 0

 'Formula for the length of the CapScrew to be used
If (designTable1.Configuration <= 15) = True Then
    Y = X - 10 - 1 + 15
    designTable2.Configuration = Y
Else
    Y = X - 12 - 1 + 15
    designTable2.Configuration = Y
End If

Solution

  • Try:

    Application.WorksheetFunction.YourFunction(YourArguments)
    

    There's often a better solution than using worksheet functions in VBA, though.