I have written some code to check test the case for cell value > 0.0007 and if it is true to delete that row and the 199 rows below. This works when the cell value is greater than 0.51, however when the cell value is between 0.0007 and 0.5 I get a runtime error.
This is my code
Sub TimeFilter()
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
Dim Time As Single
Application.StatusBar = "Performing Time Filter..."
Range("F3893").Select ' select active cell - time difference
Do
Time = ActiveCell.Value
Select Case Time
Case Is > 0.01 ' test active cell for time filter
Range(ActiveCell, Cells(ActiveCell.Row + 119, ActiveCell.Columns)).Delete ' if condition is met delete active cell and 120 rows below ***ERROR***
Selection.Cells(1, 1).Activate
Case Else
ActiveCell.Offset(1, 0).Select ' moves to next row if condition above is not met
End Select
Loop Until ActiveCell.Value = " "
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
Any help is much appreciated
Thanks
Sam
This is my code
Sub TimeFilter()
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
Dim Time As Single
Application.StatusBar = "Performing Time Filter..."
Range("F3893").Select ' select active cell - time difference
Do
Time = ActiveCell.Value
Select Case Time
Case Is > 0.01 ' test active cell for time filter
Range(ActiveCell, Cells(ActiveCell.Row + 119, ActiveCell.Columns)).Delete ' if condition is met delete active cell and 120 rows below ***ERROR***
Selection.Cells(1, 1).Activate
Case Else
ActiveCell.Offset(1, 0).Select ' moves to next row if condition above is not met
End Select
Loop Until ActiveCell.Value = " "
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
Any help is much appreciated
Thanks
Sam