+ Reply to Thread
Results 1 to 4 of 4

Macro Won't Delete Top Row

  1. #1
    Forum Contributor
    Join Date
    03-03-2011
    Location
    Ottawa, Ontario
    MS-Off Ver
    365
    Posts
    136

    Macro Won't Delete Top Row

    I have a macro that deletes any row that contains a certain word or words. I am constantly adding words to be deleted based on other criteria so I have been just adding what I need into the macro. The problem I am having is that if that word is in row 1 it seems that my macro doesn't recognize it and won't delete it. If the same word is in any other row it will be deleted just not in the first row. Here is the part of the macro that I am using to find and delete the word. Any help would be greatly appreciated.

    With ActiveSheet
    .AutoFilterMode = False
    With Range("A1", Range("A" & Rows.Count).End(xlUp))
    .AutoFilter 1, "*Word to search for*"
    On Error Resume Next
    .Offset(1).SpecialCells(12).EntireRow.Delete
    End With
    .AutoFilterMode = False
    End With

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro Won't Delete Top Row

    I think it's the Offset(1) in this line. Any luck with removing it?
    Please Login or Register  to view this content.
    should be
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-03-2011
    Location
    Ottawa, Ontario
    MS-Off Ver
    365
    Posts
    136

    Re: Macro Won't Delete Top Row

    That didn't help. Same result. Would the macro be seeing the top row as headers maybe so not recognizing anything?

  4. #4
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro Won't Delete Top Row

    It works for me. I tried more testing, but I don't have any other ideas.

    Just a minor point, why do you need "On Error Resume Next"? It doesn't display errors if there are any. Try removing it and maybe you get an error that explains why your code doesn't work the way you want it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1