+ Reply to Thread
Results 1 to 13 of 13

Delete Every Nth Row

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Delete Every Nth Row

    Hello everybody
    I found this code
    Please Login or Register  to view this content.
    It's supposed to delete every Nth row ..
    I don't know how to use it?
    I tried a lot but failed

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Delete Every Nth Row

    You need to call it from another sub, given that you have parameters involved. Try:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Delete Every Nth Row

    Mr. Berlan
    That's great and simple .. So perfect
    Thanks a lot
    I tried the code with 10000 rows .. It took very long time and I had to press Ctrl + Pause Break to stop it .. And no rows had been deleted!
    Is there a faster code that can do that task?

  4. #4
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Delete Every Nth Row

    Hi,

    I rewrote it a bit and added turned of screenupdating and calculation, etc. during the procedure (which you can integrate in your first script instead if needed). Added a parameter t

    Try this:
    Please Login or Register  to view this content.
    Best,
    berlan
    Last edited by berlan; 03-04-2015 at 11:23 AM. Reason: Notice minor edit

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete Every Nth Row

    Does this help?

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Delete Every Nth Row

    @John, only problem with that one is that it will recalculate every time you delete a row and slow down the process even more. Or if calculation is turned off, there will still be more interaction with Excel for each deletion, I'm afraid, but haven't tried on a large sample.

    berlan

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete Every Nth Row

    I tested on 10000 rows. It took less then 15 seconds. Of course room for improvement. But my first goal was to get the rows deleted.

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Delete Every Nth Row

    Thanks everybody for these great help
    I tried a combination of both codes and it took only 7 seconds for me
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete Every Nth Row

    You're welcome. I thought you wanted every 9th row, the code you posted is for every 2 rows.

  10. #10
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Delete Every Nth Row

    Here is another way.. for testing..

    Please Login or Register  to view this content.
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  11. #11
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Delete Every Nth Row

    Thanks a lot Mr. Debraj for this code
    I tried to make it delete every 2nd row by changing this line
    Please Login or Register  to view this content.
    But I encountered an error (Object required) at this line
    Please Login or Register  to view this content.

  12. #12
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Delete Every Nth Row

    ok.. I missed that part..

    Please Login or Register  to view this content.

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Delete Every Nth Row

    Thanks a lot Mr. Debraj Roy

    The code in post #8# takes about 3 seconds but your working code takes about 6 seconds !
    Although I added the parts of disabling screenupdating and calculation for your code .. But I preferred your way of thinking about using filter
    Please Login or Register  to view this content.
    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. VBA code to delete the FILTERED range and moving the cell up (dont Delete entire row)
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2015, 07:48 AM
  2. Replies: 1
    Last Post: 11-30-2013, 06:37 AM
  3. Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 08:12 PM
  4. Replies: 0
    Last Post: 06-21-2005, 01:05 PM
  5. Re: Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2005, 01:05 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