The following code is set to delete any rows within the range 'picklist' where the value of column B is set to 'No'. This was working fine but now I just get a 'run time error 1004 - delete method of range class failed' at the .entirerow.delete. Even if I go back to an earlier version of the workbook then it runs fine but when I copy the same code to the latest version of the workbook then I get the error.
Other modules called are below;Code:Const FilterString As String = "No" Dim lngLastRow As Long Dim rngToCheck As Range Dim xval As Variant Dim lcol As Long Dim xlCalc As XlCalculation Call FreezeScreen worksheets("sheet1").Unprotect With worksheets("sheet1").Range("PickList") .AutoFilter Field:=2, Criteria1:=FilterString On Error Resume Next .SpecialCells(xlCellTypeVisible).EntireRow.Delete ' gives error at this point if I remove the on error line AutoFilter.ShowAllData End With worksheets("sheet1").Protect Call UnFreezeScreen
Code:Sub FreezeScreen() With Application ' xlCalc = .Calculation ' .Calculation = xlCalculationManual .EnableEvents = False .ScreenUpdating = False End With End Sub
Any idea what is causing the error?Code:Sub UnFreezeScreen() With Application ' .Calculation = xlCalc .EnableEvents = True .ScreenUpdating = True End With End Sub




Reply With Quote