Im trying to make a macro that will multiply any matrix by another one, and ive succeded in doing it when i know the range of the matrix but i dont know how to make it work for any given matrix without having to change my i and j counter and as long as the number of rows in the first one is the same as columns in the second one, here is what i have:
Sub MultMatrices()
For i = 1 To 8
For j = 1 To 8
suma = 0
For k = 1 To 8
suma = suma + Worksheets("hoja1").Cells(i, k).Value * Worksheets("hoja2").Cells(k, j).Value
Next k
Worksheets("hoja3").Cells(i, j).Value = suma
Next j
Next i
End Sub
Bookmarks