Swansonator
New Member
- Joined
- Apr 19, 2013
- Messages
- 8
All I am trying to do is multiply two matrices together in vba. This code works if both 'a' and 'b' are square matrices, but this just returns an error, and 'c' has 'error 2015' when I'm trying to de-bug. Any help?
On a related note, how can I assign hard coded values to a 2-d array? Such as
Code:
Sub arraytest()
Dim a(1 To 2, 1 To 2) As Variant
Dim b(1 To 2, 1) As Variant
Dim c As Variant
a(1, 1) = 1
a(1, 2) = 2
a(2, 1) = 3
a(2, 2) = 4
b(1, 1) = 5
b(1, 2) = 6
c = Application.MMult(a, b)
For i = 1 To 2
Cells(i, 1) = c(i, 1)
Next i
End Sub
On a related note, how can I assign hard coded values to a 2-d array? Such as
Code:
a = array(1, 2 ; 3,4)