+ Reply to Thread
Results 1 to 13 of 13

Error 6 - Overflow. What now?

  1. #1
    Registered User
    Join Date
    09-04-2020
    Location
    Oslo
    MS-Off Ver
    Mac 2016
    Posts
    5

    Error 6 - Overflow. What now?

    I'm completely new to VBA and don't know very little programming in general.

    I am trying to run this VBA:

    hxxps : //github.com/niko86/RamerDouglasPeucker-ExcelVBA

    (not allowed to post live links)

    However I am getting an Error 6 - Overflow, and if I press Debug it points to this line:
    Please Login or Register  to view this content.
    Unfortunately I have no idea how to proceed from here. I've looked at the MS docs for both Error 6 and for the UBound function, but it's not been very fruitful.

    Any help would be appreciated.



    -----------
    Why am I trying to run this VBA? Well, I have a dataset with about 12000 datapoints. I need to graph this. But my computer is not really powerful enough to do so smoothly. So I was hoping to reduce the number of data points to about 1000. I don't need the graph to be accurate. It just needs to "look" similar enough. I'm trying to graph in GraphPad Prism. Not excel btw.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Error 6 - Overflow. What now?

    Hi there,

    It's VERY difficult to make meaningful suggestions without seeing the full code (which I can't access using the link you posted).

    The "Overflow" error means that a variable is being asked to store a value which exceeds the allowable limits for the type of variable.

    If your rowCount variable is declared (in a Dim statement) as being of type Integer, it might be worth declaring it to be of type Long and seeing if that makes a difference.

    Hope this helps.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    09-04-2020
    Location
    Oslo
    MS-Off Ver
    Mac 2016
    Posts
    5

    Re: Error 6 - Overflow. What now?

    Quote Originally Posted by Greg M View Post
    Hi there,

    It's VERY difficult to make meaningful suggestions without seeing the full code (which I can't access using the link you posted).

    The "Overflow" error means that a variable is being asked to store a value which exceeds the allowable limits for the type of variable.

    If your rowCount variable is declared (in a Dim statement) as being of type Integer, it might be worth declaring it to be of type Long and seeing if that makes a difference.

    Hope this helps.

    Regards,

    Greg M

    Here's the whole code:
    Please Login or Register  to view this content.
    I tried changing:

    Please Login or Register  to view this content.
    That produced this error:
    Please Login or Register  to view this content.
    After that the debugger points to "result = DouglasPeucker(pointList, epsilon, rowCount)"
    Last edited by jolink; 09-04-2020 at 10:10 AM.

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Error 6 - Overflow. What now?

    Two more changes required:

    Please Login or Register  to view this content.
    Rory

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Error 6 - Overflow. What now?

    Hi again,

    Thanks for posting your code.

    The "Type Mismatch" error is generated when a variable of type (e.g.) Long is passed to a routine in which the corresponding dummy argument is declared to be of type (e.g.) Integer.

    I've changed various declarations in your code to achieve consistency. Please note that I haven't attempted to understand what your code does, I've just got it to compile successfully.

    The modified code is as follows:

    Please Login or Register  to view this content.

    Hope this helps.

    Regards,

    Greg M

  6. #6
    Registered User
    Join Date
    09-04-2020
    Location
    Oslo
    MS-Off Ver
    Mac 2016
    Posts
    5

    Re: Error 6 - Overflow. What now?

    Awesome! Thank you both That cleared that problem. But now I have a new error.

    Error 13 - Type Mismatch. It points to this line.
    Please Login or Register  to view this content.
    In the instructions to use this VBA it says you need to define a range in your excel book and name it epsilon. I'm not entirely sure I've done that the correct way. Maybe that is what is giving me this error? How does VBA want you to define a range anyway?

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Error 6 - Overflow. What now?

    It needs to be a one cell range with a number in it - is it?

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Error 6 - Overflow. What now?

    epsilon is dimmed as double (a single value -- not an array). I am guessing the the range named "epsilon" consists of multiple cells. A double cannot hold a range nor an array of doubles. Try dimming epsilon as variant (it will become a variant containing an array).
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  9. #9
    Registered User
    Join Date
    09-04-2020
    Location
    Oslo
    MS-Off Ver
    Mac 2016
    Posts
    5

    Re: Error 6 - Overflow. What now?

    Quote Originally Posted by rorya View Post
    It needs to be a one cell range with a number in it - is it?
    Currently it is not. I am working from the assumption that epsilon is the target number for the macro, I want to reduce my data to 1000, so I tried creating a range that spans a 1000 cells. Probably not the way to do it eh?

  10. #10
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Error 6 - Overflow. What now?

    Hi again,

    You don't need to define a named range using VBA - you can do it, but it's probably a bit easier to do it in "native" Excel.

    On the Ribbon, click on FORMULAS >> Name Manager, and specify the name ("epsilon") of the range, and the range of cells to which you want that name to be applied.

    Hope this helps.

    Regards,

    Greg M

  11. #11
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Error 6 - Overflow. What now?

    If "epsilon" is declared as a Range, the "Type Mismatch" error you indicated can be avoided by using:

    Please Login or Register  to view this content.
    Regards,

    Greg M

  12. #12
    Registered User
    Join Date
    09-04-2020
    Location
    Oslo
    MS-Off Ver
    Mac 2016
    Posts
    5

    Re: Error 6 - Overflow. What now?

    Quote Originally Posted by Greg M View Post
    Hi again,

    You don't need to define a named range using VBA - you can do it, but it's probably a bit easier to do it in "native" Excel.

    On the Ribbon, click on FORMULAS >> Name Manager, and specify the name ("epsilon") of the range, and the range of cells to which you want that name to be applied.

    Hope this helps.

    Regards,

    Greg M
    That solved it. Now it runs as intended. Thank you so much!!

  13. #13
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Error 6 - Overflow. What now?

    Hi again,

    Many thanks for all of your feedback.

    You're welcome - glad I was able to help.

    Regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Ribbon Customization error (Long Data Type but still overflow error)
    By ImranBhatti in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-30-2018, 08:15 AM
  2. [SOLVED] OVerflow 6 error
    By Mortada in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-25-2013, 06:09 PM
  3. Explanation of the Run-time error '6': Overflow Error
    By mgphill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2012, 10:46 AM
  4. Want to do a while-loop but get error message: run error '6' overflow
    By danzi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2011, 01:48 PM
  5. Overflow Error
    By transparencia in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2010, 02:21 PM
  6. Overflow Error
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-10-2010, 02:08 AM
  7. Overflow error
    By Jim Berglund in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2005, 02:06 PM

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