njrobby
10-04-2015, 08:20 PM
Hello,
Yes, I'm a student with an assignment.
But, I fell like I'm most of the way to my solution, although my code isn't working.
I have written the code below to calculate the product of two matrices but I keep getting #NAME? instead of a matrix.
14503
I'm running in Excel - Microsoft Visual Basic 14.5.5 for Mac
Any help would be much appreciated!
Thanks
Public Function MultMatrix(A As Range, b As Range) As Variant
'Define Variables
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim C() As Variant
Dim Ctemp As Variant
'Dim A() As Variant
'Set initial Values
i = 1
j = 1
k = 1
C(i, j) = 0
'Matrix Multiplication
For i = 1 To 3
For j = 1 To 3
For k = 1 To 3
Ctemp = A(i, j).Value * b(j, i).Value
C(i, j).Value = C(i, j).Value + Ctemp
A(i, j) = C(i, j) + Ctemp(i, j) + A(i, j)
Next k
Exit For
Next j
Exit For
Next i
'Exit For
End Function
Yes, I'm a student with an assignment.
But, I fell like I'm most of the way to my solution, although my code isn't working.
I have written the code below to calculate the product of two matrices but I keep getting #NAME? instead of a matrix.
14503
I'm running in Excel - Microsoft Visual Basic 14.5.5 for Mac
Any help would be much appreciated!
Thanks
Public Function MultMatrix(A As Range, b As Range) As Variant
'Define Variables
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim C() As Variant
Dim Ctemp As Variant
'Dim A() As Variant
'Set initial Values
i = 1
j = 1
k = 1
C(i, j) = 0
'Matrix Multiplication
For i = 1 To 3
For j = 1 To 3
For k = 1 To 3
Ctemp = A(i, j).Value * b(j, i).Value
C(i, j).Value = C(i, j).Value + Ctemp
A(i, j) = C(i, j) + Ctemp(i, j) + A(i, j)
Next k
Exit For
Next j
Exit For
Next i
'Exit For
End Function