(Solved) – Return Array to Parent Subroutine From Called Function



I am running into a problem passing a 2-D array from a called function back to the subroutine that called it.


Sub Rotate_Stiffness_3D()
'Setting Things Up
Dim Theta_p As Double
Dim Theta_q As Double
Dim Theta_r As Double
Dim Tep(6, 6) As Double
Dim Teq(6, 6) As Double
Dim Ter(6, 6) As Double

Theta_p = Sheets("Transformations").Cells(2, 3)
Theta_q = Sheets("Transformations").Cells(3, 3)
Theta_r = Sheets("Transformations").Cells(4, 3)
Tep = Get_Tep (Theta_p)
End Sub

Function Get_Tep(Theta_p As Double) As Variant
'Setting things Up
Dim cp As Double
Dim sp As Double
Dim t(6, 6) As Double

cp = Cos(Theta_p)
sp = Sin(Theta_p)

t(1, 1) = 1
t(1, 2) = 0  'This continues for a while
t(6, 5) = sp
t(6, 6) = cp
Return t
End Function

However, I continually get compiler errors on the Return t and Tep = Get_Tep (Theta_p) lines of code. I’m not sure what I am doing wrong…

Leave a Reply

Your email address will not be published. Required fields are marked *