0% found this document useful (0 votes)
3 views1 page

GRASP Python (10)

The document outlines a VBA function and subroutine for displaying results in an Excel worksheet. It creates a 'Results' worksheet, populates it with nodal displacements and support reactions, and formats the data as tables. The code includes error handling for existing worksheets and organizes the output for clarity.

Uploaded by

Le Fondateur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

GRASP Python (10)

The document outlines a VBA function and subroutine for displaying results in an Excel worksheet. It creates a 'Results' worksheet, populates it with nodal displacements and support reactions, and formats the data as tables. The code includes error handling for existing worksheets and organizes the output for clarity.

Uploaded by

Le Fondateur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

End If

' Return empty array to indicate failure


ReDim result(0)
SolveDirect = result
End Function

Sub DisplayResults(displacements() As Double, reactions() As Double,


elementForces() As Variant)
' Enhanced results display with multiple worksheets

' Create results worksheet


Dim wsResults As Worksheet
On Error Resume Next
Set wsResults = ThisWorkbook.Worksheets("Results")
If Not wsResults Is Nothing Then
Application.DisplayAlerts = False
wsResults.Delete
Application.DisplayAlerts = True
End If
On Error GoTo 0

Set wsResults =
ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Worksheets(ThisWorkbook.Works
heets.Count))
wsResults.Name = "Results"

' Write nodal displacements


wsResults.Cells(1, 1).Value = "Node Displacements"
wsResults.Cells(2, 1).Value = "Node"
wsResults.Cells(2, 2).Value = "UX (m)"
wsResults.Cells(2, 3).Value = "UY (m)"
wsResults.Cells(2, 4).Value = "RZ (rad)"

Dim nodeId As Integer, row As Integer


row = 3
For nodeId = 1 To nodes.Count
wsResults.Cells(row, 1).Value = "N" & nodeId
wsResults.Cells(row, 2).Value = displacements(3 * (nodeId - 1) + 1)
wsResults.Cells(row, 3).Value = displacements(3 * (nodeId - 1) + 2)
wsResults.Cells(row, 4).Value = displacements(3 * (nodeId - 1) + 3)
row = row + 1
Next nodeId

' Format as table


wsResults.ListObjects.Add(xlSrcRange, wsResults.Range("A1:D" & row - 1),
, xlYes).Name = "Displacements"

' Write reactions


row = row + 2
wsResults.Cells(row, 1).Value = "Support Reactions"
row = row + 1
wsResults.Cells(row, 1).Value = "Node"
wsResults.Cells(row, 2).Value = "RX (N)"
wsResults.Cells(row, 3).Value = "RY (N)"
wsResults.Cells(row, 4).Value = "MZ (Nm)"

P a g e 58 | 62

You might also like