Results 1 to 11 of 11

Thread: Delete all rows under a group

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location
    Quote Originally Posted by Klartigue
    There is an error that says object variable or With block variable not set
    Presuming there are never going to be any data rows below the row containing the cell with the value, "Closed Accounts," that you want to retain, the following might work for you (of course you may need to change your sheet name as applicable):

    Sub testing()
        Dim rng As Range, fRow, lRow As Integer
        With Sheets("Sheet1")
            lRow = .UsedRange.Rows.Count
            fRow = .Range("B:B").Find(what:="Closed Accounts").Row
            Set rng = .Range("B" & fRow, .Range("B" & lRow))
            rng.EntireRow.Delete
        End With
    End Sub
    Last edited by Aussiebear; 02-24-2025 at 03:40 AM.

Posting Permissions

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