Row removed based on criteria

  • I have this code that I wrote to remove all rows across all sheets that have the text, actual:, in it but doesn't work. Keep getting the error Next without for, but not sure where exactly to edit it.

    Code
    Sub Removetextrow()[/FONT][/COLOR][COLOR=black][FONT=Verdana] [/FONT][/COLOR][COLOR=black][FONT=Verdana] Dim WS As Worksheet Application.ScreenUpdating = False    Application.Calculation = xlCalculationManual   For Each WS In ActiveWorkbook.Worksheets       With WSWith WS.UsedRange[/FONT][/COLOR][COLOR=black][FONT=Verdana]Do        Cells.Find(What:="Actual:", After:=ActiveCell, LookIn:=xlValues, LookAt _        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _        False, SearchFormat:=False).Activate    Selection.EntireRow.DeleteLoop[/FONT][/COLOR][COLOR=black][FONT=Verdana]   End With    Next WS    Application.ScreenUpdating = True    Application.Calculation = xlCalculationManualEnd Sub

    [/FONT][/COLOR]
    Any help will be greatly appreciated.

  • Re: Row removed based on criteria


    Quote from jproffer;603205

    You're missing an End With after the other End With and before "Next WS"


    Okay thanx that helped but now I just need to find out a way to get over the next error/ hurdle, which is run time error 91, object variable or with block variable not set


  • Re: Row removed based on criteria


    Try this one:


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!