morning everyone hoping you could help out. below is code for extracting the x and y parameters for a spline function. i am getting a run time error 6 at the bold line, when j=7, step=32767, nstep=630.
tips/suggestions would be incredible. please and thanks
Sub plotter()
'Data sizing
Dim x(126) As Double, y(126) As Double, norder As Integer, nstep As Integer
Dim h(126) As Double
Dim i As Integer, j As Integer, step As Integer
Dim B(126) As Double, D(126) As Double, A(126) As Double, C(126) As Double
Dim xs As Double, ys As Double
'Read in data-point order
norder = ActiveSheet.Cells(3, 3)
'Read in Cubic properties
For i = 1 To norder
x(i) = ActiveSheet.Cells(4 + i, 3)
h(i) = ActiveSheet.Cells(4 + i, 5)
A(i) = ActiveSheet.Cells(4 + i, 8)
B(i) = ActiveSheet.Cells(4 + i, 9)
C(i) = ActiveSheet.Cells(4 + i, 10)
D(i) = ActiveSheet.Cells(4 + i, 11)
Next i
'Read in steps
nstep = ActiveSheet.Cells(3, 1)
'Determine and write out x,Y
step = 1
For i = 1 To (norder - 1) 'Discrete function step
For j = 1 To nstep
step = step + 1
xs = x(i) + (h(i) / nstep) * (j - 1)
ys = A(i) * (xs - x(i)) ^ 3 + B(i) * (xs - x(i)) ^ 2 + C(i) * (xs - x(i)) + D(i)
ActiveSheet.Cells(step, 15) = xs
ActiveSheet.Cells(step, 16) = ys
Next j
Next i
End Sub
Bookmarks