+ Reply to Thread
Results 1 to 6 of 6

delete all visible rows after a filter

  1. #1
    Forum Contributor
    Join Date
    03-27-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    290

    delete all visible rows after a filter

    im trying to use this code but it doesnt work and im not sure why

    Please Login or Register  to view this content.
    the delete part is whats at fault, im sure you can see what im trying to do though...

    any ideas?

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: delete all visible rows after a filter

    You have xlAnd
    which requires second criteria.

  3. #3
    Forum Contributor
    Join Date
    05-29-2013
    Location
    MD
    MS-Off Ver
    Excel 365
    Posts
    148

    Re: delete all visible rows after a filter

    If you are selecting A1, it will delete your header row and filter too. You should change that to A2. If it's not visible in the filter it won't get deleted.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    03-27-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    290

    Re: delete all visible rows after a filter

    this works further up in my macro however fails further down and im not sure why...

    heres my code:

    Please Login or Register  to view this content.
    I tried & Lastrow but that didnt work so I tried to change it to 100000 just to see if it would make a difference.

    it didnt.

    EDIT: is it because the A2 row is hidden?

    the error I get is: "delete method of range class failed"

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: delete all visible rows after a filter

    Untested code.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    03-27-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    290

    Re: delete all visible rows after a filter

    I have this which works...
    Please Login or Register  to view this content.
    Then some more code, which is also working fine...
    then this:

    Please Login or Register  to view this content.
    which fails at the Delete row...
    why does this one fail but the other one doesnt?

+ 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