+ Reply to Thread
Results 1 to 4 of 4

run time error 6

Hybrid View

  1. #1
    Registered User
    Join Date
    02-11-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    98

    run time error 6

    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

  2. #2
    Registered User
    Join Date
    02-11-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    98

    Re: run time error 6

    i changed the dimensions from integer to long. will give that a shot

  3. #3
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: run time error 6

    declare step as Long
    right now you have it as integer so you can only index up to 32,767

    Best Regards

  4. #4
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: run time error 6

    Hi

    Try Dimming these as Long instead of Integer

    Dim i As Integer, j As Integer, step As Integer
    --
    Regards
    Roger Govier
    Microsoft Excel MVP

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1