Hi

I've written code to go through each row of a spreadsheet, and delete any rows where the date does not fall within a specific range.

Unfortunatly on my spreadsheet I occasionally get large numbers in the date column due to corruption. I was hoping the 'isdate' function would allow me to remove these but I keep getting an <Overflow> when trying to read out the value using Range.Value

Exact error on the isdate line: Range("M" & curRow).Value = <Overflow>

Why won't it allow me to read this value out? The actual value in this case is 1.58456325028529E+29.. surely not too big for VB to handle??

Code below:

Code:
 noRows = Worksheets(1).UsedRange.Rows.Count
    Dim curRow As Long
    Dim thisDate As Date
    curRow = 2 
    Do While curRow < noRows + 1
        'check valid date
        If IsDate(Range("M" & curRow).Value) Then
            
            thisDate = Range("M" & curRow).Value
            
            If thisDate >= dtFromDate And thisDate <= dtToDate Then
                inRange = True
            Else
                inRange = False
            End If
    
            If inRange = False Then
                Rows(curRow & ":" & curRow).Select
                Selection.ClearContents
            End If
        Else ' clear if not valid date
            Rows(curRow & ":" & curRow).Select
            Selection.ClearContents
        End If 
        curRow = curRow + 1
    Loop
Any help would be appreciated, ive tried researching the common causes of overflow and yeilded no results :/

303factory