+ Reply to Thread
Results 1 to 8 of 8

Delete lines with autfilter

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Delete lines with autfilter

    Ok so I had a macro working just fine, but now I had to make some changes to it.
    As a result now it crashes on another line of code with regards to delete certain rows after a autofilter has been applied.
    This is the code now giving errors :
    Sheet2.AutoFilter.Range.Offset(1, 0).Delete Shift:=xlUp (where are the quotes??)

    It is caused by the offset part but did always work before.
    Getting the appl-defined or object-defined error....

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: Delete lines with autfilter

    Replace
    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Delete lines with autfilter

    Thanks Bernie.
    But unfortunately this generates the same error message.
    While in debug the line with Offset gets highlighted in yellow

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: Delete lines with autfilter

    The code worked for me - is your sheet filtered? Protected? Do you have merged cells? Do you have an example workbook where the code fails?

  5. #5
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Delete lines with autfilter

    Well yes my sheet is filtered as it is the filtered lines that I want to delete.
    The code first copies these lines to another sheet and then needs to delete these lines from the source sheet.
    Nothing protected and no merged cells.

    It is a pretty big model which imports it data and then does several operations on the data.
    So it is really not easy to share....

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: Delete lines with autfilter

    The "imports data" part - how do you import data?

    What do you get with this line:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Delete lines with autfilter

    it gives A$:X$

    Maybe helpful, only thing I changed in the code causing this problem was me changing a text to columns (to get numbers instead of text) with this:
    With Sheet2.Range("U:U")
    .NumberFormat = "General"
    .Value = .Value
    End With

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,517

    Re: Delete lines with autfilter

    Have a look at #3 in "Forum Rules" at the top about placing your code between code tags.
    Show us all the code you have.

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: Delete lines with autfilter

    You cannot offset an entire column by one row - that is off the bottom of the sheet. You can either limit it to the used range:

    Please Login or Register  to view this content.
    or switch the offset and resize:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. delete lines
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-17-2014, 04:47 PM
  2. Can't delete Lines
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-27-2014, 10:31 AM
  3. [SOLVED] Macro to Delete useless lines, rearrange by dates and skip lines between different days.
    By Tmc2159 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-12-2012, 02:15 PM
  4. how to delete lines
    By macedo in forum Excel General
    Replies: 3
    Last Post: 03-21-2012, 08:06 AM
  5. Delete Lines 2
    By RobB11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2011, 01:20 AM
  6. Delete Lines
    By RobB11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2011, 02:52 PM
  7. Delete Lines
    By Shark Man in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2010, 02:20 PM

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