+ Reply to Thread
Results 1 to 11 of 11

Delete entire row based on multiple cell values

  1. #1
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Delete entire row based on multiple cell values

    Hi,

    I want to delete entire rows and shift the rows up if column I and J are BOTH equal to zero. It's that simple!

    Since this is in the middle of a larger macro, it might be safe to specify that it's for sheet 'Final Import'.

    Could anyone help me with this?

    Thanks!!
    Last edited by The Phil; 04-08-2015 at 05:53 PM.

  2. #2
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: Delete entire row based on multiple cell values

    May not be most elegant way but this will work. You should be able to easily adapt it.
    Please Login or Register  to view this content.
    If this helped, please click (*) Add Reputation

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Delete entire row based on multiple cell values

    Another option

    Please Login or Register  to view this content.
    Last edited by stnkynts; 04-08-2015 at 05:04 PM.

  4. #4
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Delete entire row based on multiple cell values

    Hmm, it seems to work, but I'm having some issues. I watched it start and select the first row where there were zero values, then a couple seconds later it deleted the row, then a couple seconds later it selected the next row that matched the criteria, then a couple seconds later it deleted it. It seems to be running super slow for some reason.

    I added the following and tried again and it was still super slow.

    Please Login or Register  to view this content.
    Any ideas on why it would be running so slowly?

    Thanks

  5. #5
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Delete entire row based on multiple cell values

    I tried reducing my data down to 52 rows and ran both of your scripts. They work, but it takes them each a couple of minutes to delete 5 out of 52 rows. It seems that it should only take a couple of seconds.

    If I step through the macros, it seems to hang on both when there is a delete command, so for some reason that command takes a few seconds to process instead of simply deleting the row in a fraction of a second.

    I've been googling why this may be and can't find anything.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Delete entire row based on multiple cell values

    Hmmmmm. The solution I provided should be almost instantaneous. Submit your workbook.

  7. #7
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Delete entire row based on multiple cell values

    Hi,

    Something else in my workbook must be causing it. I can't submit it because there is too much corporate data in it.

    I found out that if I manually select a row and delete row, it also takes a couple seconds, so it's not the code. I have formulas set to manual, and there's nothing referring to that sheet, and that sheet doesn't refer to anything else. Something about deleting rows with or without a macro is running very slowly.

    Thanks for the code though, it looks like it works great!!

  8. #8
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: Delete entire row based on multiple cell values

    Not sure why. I tried it on 200 rows and it was very quick.

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

    Re: Delete entire row based on multiple cell values

    Not considering autofilter, this should be a good alternative:
    Please Login or Register  to view this content.
    Regards,
    berlan
    Last edited by berlan; 04-08-2015 at 06:23 PM.

  10. #10
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Delete entire row based on multiple cell values

    On a different sheet I had a huge block of complicated formulas. It was 4 columns and about 11,200 rows of formulas. I deleted them and everything worked very quickly.

    I'm not sure why that would be though. None of them referred to the sheet that this macro was touching, and the sheet that this macro was touching doesn't refer to any other sheet. I had also set the recalculation to be manual.

    Oh well, I'll have to work around it.

  11. #11
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Delete entire row based on multiple cell values

    Did you properly turn off the calculations?

    Please Login or Register  to view this content.
    Note Application.Calculation = Manual is not correct. It will do nothing.

+ 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 entire rows based on cell value in multiple sheets
    By forquaidian in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2014, 05:31 AM
  2. Replies: 3
    Last Post: 11-06-2012, 11:26 AM
  3. delete rows based on multiple cell values
    By Eddie2012 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-06-2012, 12:04 PM
  4. macro to delete entire row based on TWO cell values
    By uncleslinky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2011, 02:42 PM
  5. Macro to delete entire rows based values in columns
    By shamade2107 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2009, 11:17 AM

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