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