title: Passing rows or columns from a sheet to a VBA function
body: <p>I have written a VBA code that solves a set of algebraic equations of the form </p>
  
  <p>A(i)X(i-1)+B(i)X(i)+C(i)X(i+1)=R(i)</p>
  
  <p>A portion of the function is given below.  Currently, the coefficients A, B, C, and R have to be stored in columns in the main worksheet to be passed to the function.   Is there a way to provide the flexibility of having the coefficients either in rows or columns?  </p>
  
  <pre><code>Function TRIDI(ByVal Ac As Range, ByVal Bc As Range, ByVal Cc As Range, _
  ByVal Rc As Range) As Variant
  Dim BN As Single
  Dim i As Integer
  Dim II As Integer
  Dim A() As Single, B() As Single, C() As Single, R() As Single, X() As Single
  N = Ac.Rows.Count
  ReDim A(N), B(N), C(N), R(N), X(N)
  For i = 1 To N
  A(i) = Ac.Parent.Cells(Ac.Row + i - 1, Ac.Column)
  B(i) = Bc.Parent.Cells(Bc.Row + i - 1, Bc.Column)
  C(i) = Cc.Parent.Cells(Cc.Row + i - 1, Cc.Column)
  R(i) = Rc.Parent.Cells(Rc.Row + i - 1, Rc.Column)
  Next i
  </code></pre>