Select Case – Active Cell Delete

Hi, I have written some code to loop down a column in a spreadsheet and test for case is >0.001, this works when the cell value is greater than 0.5, however for anything less I am getting a Run time error ‘1004’ : Appliocation defined or object defined error. Can anyone help?

My code is below

Option Explicit

Sub TimeFilter()

Application.ScreenUpdating = False
Application.DisplayStatusBar = True

Dim Time As Single
Dim a As Integer

Application.StatusBar = “Performing Time Filter…”
Range(“F7”).Select ‘ select active cell – time difference

a = ActiveCell.Row

Time = ActiveCell.Value
Select Case Time

Case Is > 0.001 ‘ 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
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 a = 10090

Application.StatusBar = False
Application.ScreenUpdating = True

End Sub




By: Sam Tetley

Leave a Reply

Your email address will not be published. Required fields are marked *