Results 1 to 4 of 4

Thread: Overflow error in Excel macro

Threaded View

  1. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Overflow error in Excel macro

    Thread moved to Office Development/VBA forum (note that the "VB Editor" in Office programs is actually VBA rather than VB)

    The "overflow" error always means that the number is too big for the data type... and it is not surprising that it is occurring here, as that number is huge, certainly more than can be stored to a Date data type (which is part of what IsDate will check).

    What I would recommend is trying to store the value to a Double instead (as it supports numbers that large), and/or see if that value is bigger than the largest Date allowed (I'm not sure if VBA has the same maximum as VB, but for VB it is #12/31/9999#).

    eg:
    Code:
      If CDbl(Range("M" & curRow).Value) < #12/31/9999# Then
           'valid date
      Else
           'not a valid date
      End If
    ..of course you could use a lower "maximum" date that makes more sense to you, as I doubt you have any valid data after the year 2099 or so!
    Last edited by si_the_geek; Apr 16th, 2008 at 06:01 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width