Function Dot(y As Range, x As Range) As Variant

Dim A() As Double

Dim i As Integer, n As Integer, nr As Integer, nc As Integer 'where the matrix dimensions of y are (i, n)

Dim j As Integer, m As Integer, ns As Integer, nd As Integer 'where the matrix dimensions of x are (j, m)

nr = y.Rows.Count

nc = y.Columns.Count

ns = x.Rows.Count

nd = x.Columns.Count

If nr <> ns Then

MsgBox ("vectors are not of same length")

Exit Function

End If

ReDim A(1 To 1, 1 To nc, 1 To 1, 1 To nd) As Double

For n = 1 To nc

For m = 1 To nd

A(1, n, 1, m) = 0

For i = 1 To 1

For j = 1 To 1

A(1, n, 1, m) = A(1, n, 1, m) + (y(i, n) * x(j, m))

Next j

Next i

Next m

Next n

Dot = A

End Function