Column values: U2:U13
Matrix values: X16:AI27
Output cells: V2:V13
Formula: =Tocol(Mmult(Transpose(U2:U13), X16:AI27)
(Below is a wrong code. Any simple way to achieve this?)
>>> use code - tags <<<
Reg! (Ive exhausted free VBA code generator free previleges, any 100% free websites?)
Matrix values: X16:AI27
Output cells: V2:V13
Formula: =Tocol(Mmult(Transpose(U2:U13), X16:AI27)
(Below is a wrong code. Any simple way to achieve this?)
>>> use code - tags <<<
Code:
Sub CalculateMatrixProduct()
Dim colVector As Range
Dim matrixRange As Range
Dim outputRange As Range
Dim result As Variant
Dim i As Long, j As Long
' Set the column vector range (U2:U13)
Set colVector = Sheets("Sheet2").Range("U2:U13")
' Set the matrix range (X16:AI27)
Set matrixRange = Sheets("Sheet2").Range("X16:AI27")
' Set the output range (V2:V13)
Set outputRange = Sheets("Sheet2").Range("V2:V13")
' Calculate the matrix product
result = WorksheetFunction.MMult(Application.WorksheetFunction.Transpose(colVector), matrixRange)
' Populate the result in the output range
For i = 1 To UBound(result, 1)
outputRange.Cells(i, 1).Value = result(i, 1)
Next i
End Sub
Last edited by a moderator: