Dear all,

I have the following VBA code (shown below) which activates a row delete loop if one or more conditions are met. However, I only want to activate the loop if for a given row in column F (column 6), the value is greater than 10000. The code as it stands is:

Option Explicit

Sub CellBuster()
   Dim lCount As Double
   Dim lRows As Double
   Application.ScreenUpdating = False
   Application.Calculation = xlCalculationManual
   lRows = ActiveSheet.UsedRange.Rows.Count
   For lCount = lRows To 1 Step -1
       If Cells(lCount, 6).Value > 1.5 * Cells(lCount, 6).Offset(, -1).Value Then
           Cells(lCount, 6).EntireRow.Delete
       ElseIf Cells(lCount, 6).Value > 1.5 * Cells(lCount, 6).Offset(, -2).Value Then
           Cells(lCount, 6).EntireRow.Delete
       ElseIf Cells(lCount, 6).Value > 1.5 * Cells(lCount, 6).Offset(, -3).Value Then
           Cells(lCount, 6).EntireRow.Delete
       End If
   Next
   Application.ScreenUpdating = True
   Application.Calculation = xlCalculationAutomatic
End Sub
This version appears to work.

My attempt to include the previously mentioned extension is as follows:

Option Explicit

Sub CellBuster()
   Dim lCount As Double
   Dim lRows As Double
   Application.ScreenUpdating = False
   Application.Calculation = xlCalculationManual
   lRows = ActiveSheet.UsedRange.Rows.Count
   If Cells(lRows, 6).Value > 10000 Then
   For lCount = lRows To 1 Step -1
       If Cells(lCount, 6).Value > 1.5 * Cells(lCount, 6).Offset(, -1).Value Then
           Cells(lCount, 6).EntireRow.Delete
       ElseIf Cells(lCount, 6).Value > 1.5 * Cells(lCount, 6).Offset(, -2).Value Then
           Cells(lCount, 6).EntireRow.Delete
       ElseIf Cells(lCount, 6).Value > 1.5 * Cells(lCount, 6).Offset(, -3).Value Then
           Cells(lCount, 6).EntireRow.Delete
       End If
   Next
   End If
   Application.ScreenUpdating = True
   Application.Calculation = xlCalculationAutomatic
End Sub
However, although I get no errors, the code appears to do nothing (i.e. doesn't delete any rows), even though there are cells of greater value than 10000 in column F.

Would someone be able to provide some advice as to what I'm doing wrong please?

Thanks
smurray444