Re: VBA finding end of array within function

forum.ozgrid.com/index.php?attachment/64206/

It still not continuing through to end of row. I don't know why Ozgrid won't allow me to upload the file with the array and cspline modules, so this attachment only has the macro code - i believe you have an earlier iteration with those modules which are needed. I've also included the macro coding below:

```
Sub DepthSeries()
'
' finds maximum depth recorded and uses number to produce number series for spline array
'
'
Sheet1.range("G1").FormulaR1C1 = "=MAX(C[-6])"
range("G2").Select
Call CSplineDepth1(Sheet1.range("G2"), "Depth", Sheet1.range("A3"), Sheet1.range("G1"), 1)
End Sub
Sub CSplineDepth1(StartCell As range, Header As String, FirstN As Integer, LastN As Integer, StepN As Integer)
' Integer version produces series to maximum depth for array interpolation
Dim i As Integer ' Value
Dim r As Integer ' row
StartCell.Cells(1).Value = Header ' Cells(1) makes sure it only uses the first cell of passed-in range
' in case you pass in a multi-celled range for StartCell
i = FirstN
r = 1
Application.ScreenUpdating = False ' Much faster, so the screen is not refreshed until all the values in place
For i = FirstN To LastN Step StepN
StartCell.Cells(1).Offset(r, 0).Value = i
i = i
r = r + 1
Next i
Application.ScreenUpdating = True
' Excel formula that produces array for DepthSeries
' Range("H3:H" & lastRow).FormulaArray = CSplineA($A$2:$A$578,B$2:B$578,$G$2:$G$12322)
' Range("I3:I" & lastRow).FormulaArray = CSplineA($A$2:$A$578,C$2:C$578,$G$2:$G$12322)
' Range("J3:J" & lastRow).FormulaArray = CSplineA($A$2:$A$578,D$2:D$578,$G$2:$G$12322)
' Range("K3:K" & lastRow).FormulaArray = CSplineA($A$2:$A$578,E$2:E$578,$G$2:$G$12322)
' below is vba code used to automate cspline function
lastRow = range("A" & Rows.Count).End(xlUp).Row
range("H3:H" & lastRow).FormulaArray = "=csplinea(R3C1:R" & lastRow & "C1,R3C2:R" & lastRow & "C3,R3C7:R" & range("A" & lastRow) - range("A3") + 1 & "C7)"
range("I3:I" & lastRow).FormulaArray = "=csplinea(R3C1:R" & lastRow & "C1,R3C3:R" & lastRow & "C3,R3C7:R" & range("A" & lastRow) - range("A3") + 1 & "C7)"
range("J3:J" & lastRow).FormulaArray = "=csplinea(R3C1:R" & lastRow & "C1,R3C4:R" & lastRow & "C3,R3C7:R" & range("A" & lastRow) - range("A3") + 1 & "C7)"
range("K3:K" & lastRow).FormulaArray = "=csplinea(R3C1:R" & lastRow & "C1,R3C3:R" & lastRow & "C3,R3C7:R" & range("A" & lastRow) - range("A3") + 1 & "C7)"
End Sub ' CSplineDepth1
```

Display More