+ Reply to Thread
Results 1 to 7 of 7

Any faster way to delete hidden rows of data

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Any faster way to delete hidden rows of data

    Hi,

    I have the following code which i use to delete hidden rows. Unfortunately, its kinda slow........it takes about 86 sec to delete ~ 2749 rows of data. Is there a faster way to delete hidden rows?


    Please Login or Register  to view this content.

    What i am doing is this.I have a worksheet of data. I am filtering on this data so that after filtering i have what i want to "keep". Those things i dont want to keep are "hidden"....so i am removing the hidden files. And what i am left with is only that which i want to keep.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Any faster way to delete hidden rows of data

    For one, remove the line

    Please Login or Register  to view this content.
    that will slow things

    Also, why not use the filter to filter what you don't want and delete in one whack instead of looping.
    HTH
    Regards, Jeff

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Any faster way to delete hidden rows of data

    I would work the other way, i.e. set up your filter so that it hides the rows that you want to keep and then delete the visible cells and then restore the filter. You can do this (manually) by GoTo | Special | Visible Cells, and then you can delete in one operation. You can use SpecialCells in a macro, but I'm not sure of the exact syntax - perhaps you could record a macro while you do it manually.

    Hope this helps.

    Pete

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Any faster way to delete hidden rows of data

    i will try what you guys suggested. I may have questions about exactly how to do what your suggesting........

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Any faster way to delete hidden rows of data

    Here is an example of what I was referring too:

    Please Login or Register  to view this content.
    Put in the criteria what you want deleted and change the column reference to meet your requirements.

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Any faster way to delete hidden rows of data

    thanks jefferybrown,

    i thought i understood what you were saying but apparently i did not. I tried your code........IT WORKED GREAT and MUCH MUCH MUCH FASTER than the other way. Your way took about 0.09sec vs about 80seconds the way i was doing it.

    thanks.......i will have to review your code in more detail to figure out exactly what is going on.

    thanks.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Any faster way to delete hidden rows of data

    Glad to hear it worked out for you and thanks for the feedback

+ 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