Results 1 to 3 of 3

Thread: Prevent first row to be deleted
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Aug 2009
    Location
    Netherlands
    Posts
    108
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Prevent first row to be deleted

    Hi,

    This is part of my code:
    Code:
            .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown)).AutoFilter Field:=1, _
                Criteria1:="xxxx"
            .Cells.SpecialCells(xlCellTypeVisible).EntireRow.Delete
    This code will also delete the first row (header) in my sheet. Is there a way to exclude the first row and prevent it form being deleted?
    Grtz,
    Ronald

  2. #2
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    35,315
    Post Thanks / Like
    Mentioned
    93 Post(s)
    Tagged
    33 Thread(s)

    Default Re: Prevent first row to be deleted

    Quote Originally Posted by RonEmm View Post
    Hi,

    This is part of my code:
    Code:
            .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown)).AutoFilter Field:=1, _
                Criteria1:="xxxx"
            .Cells.SpecialCells(xlCellTypeVisible).EntireRow.Delete
    This code will also delete the first row (header) in my sheet. Is there a way to exclude the first row and prevent it form being deleted?
    Maybe this in place of what you posted...
    Code:
    With .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
      .AutoFilter Field:=1, Criteria1:="xxxx"
       .SpecialCells(xlCellTypeVisible).EntireRow.Delete
    End With
    Last edited by Rick Rothstein; Oct 16th, 2019 at 06:32 AM.
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  3. #3
    Board Regular
    Join Date
    Aug 2009
    Location
    Netherlands
    Posts
    108
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Prevent first row to be deleted

    Thanks Rick. This did the job.
    Grtz,
    Ronald

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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