Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts

    Deleting Rows containing the word Total (2007)

    I need A macro that will delete the row containing the word "Total" for eg "total Account" or "Totals for sept" etc as well as the row above it, where this appears in Col A

    It have tried the following code below, but cannot get it to work

    Sub Delete_Rows()
    With Application
    .ScreenUpdating = False
    End With
    FinalRow = Cells(65536, 1).End(xlUp).Row
    For I = 4 To FinalRow
    If Cells(I, 1).Value = "*Total.*" Then
    Cells(I, 1).Offset(-1).Resize(1).EntireRow.Delete
    End If
    Next I
    End Sub

    Your assistance with the above will be most appreciated

    Regards

    Howard

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Deleting Rows containing the word Total (2007)

    Try
    <code>
    Sub Delete_Rows()
    Dim I As Long, FinalRow As Long
    Application.ScreenUpdating = False
    FinalRow = Cells(65536, 1).End(xlUp).Row
    For I = FinalRow To 4 Step -1
    If Cells(I, 1).Value Like "*Total*" Then
    Cells(I, 1).Offset(-1, 0).Resize(2, 1).EntireRow.Delete
    End If
    Next I
    Application.ScreenUpdating = True
    End Sub</code>

  3. #3
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts

    Re: Deleting Rows containing the word Total (2007)

    Hi Hans

    Thanks for the help

    Regards

    Howard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •