Hi, I have a function where you introduce a range of cells (lets say C1:D124) and 2 other values. It also defines 4 matrices A1,A2,B1,B2 whos values are defined by the range of chosen cells.
Function plane(P1 As Range, x1 As Double, y1 As Double) As Double

Dim A1(3, 3) As Double
Dim A2(4, 2) As Double
Dim B1(3, 3) As Double
Dim B2(5, 2) As Double
A1(1, 1) = P1(1, 1)
A1(1, 2) = P1(1, 2)
A1(1, 3) = P1(1, 3)
.
.
.
If Pylo(x1, y1, A2)=1 then
     plane = TLA(A1, x1, y1)
.
.
I am getting a VALUE! error in the cell I use my function but I can`t see why. My other function inputs are the following;

Public Function PtInPoly(Xcoord As Double, Ycoord As Double, Polygon As Variant) As Variant
  Dim x As Long, NumSidesCrossed As Long, m As Double, B As Double, Poly As Variant
Function TLA(P As Variant, x As Double, y As Double) As Double
Dim Z As Double, D(6) As Double
Dim A(3, 3) As Double
I am quite sure the error is somewhere over here. I am new in VBA and below average at programming, any help is appreciated!