+ Reply to Thread
Results 1 to 3 of 3

VBA coding - If Cells.value = 0, then Delete entire row.

  1. #1
    Registered User
    Join Date
    03-13-2014
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    25

    VBA coding - If Cells.value = 0, then Delete entire row.

    Hi Guys,

    Basically, I have a table of data and I want to make a VBA coding so that Any row with "cell value = 0 in column C" will be deleted.
    But i can't get my code working and i don't know why. There's no error pop up either.
    Please Help,
    Thanks guys.

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA coding - If Cells.value = 0, then Delete entire row.

    Difficult to say without seeing in the context of its workbook.

    But before going down the looping macro, step back a bit. This question really should be a FAQ. I see it time and time again and looping just isn't the best way of doing this sort of thing. Loops should only be used as a last resort since they can be very slow when many rows are involved.

    The fastest way I know of doing this is to use an autofilter starting at C11 and filter for blanks. Then select all the filtered rows using the .SpecialCells(xlCellTypeVisible) construct and delete them all, finally removing the filter.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: VBA coding - If Cells.value = 0, then Delete entire row.

    Doesn't look anything wrong with the code ... unless row 309 is actually the last row of data and there are no gaps in the data.

    Maybe try:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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 row if cells in col A have more than 3 characters
    By cad1610 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-19-2018, 01:41 AM
  2. Compare two cells, if blank delete entire row
    By taichi56 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2013, 02:05 PM
  3. [SOLVED] How to Delete Entire Row if Range of Cells are Blank?
    By mrodrigues in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-10-2012, 09:42 PM
  4. delete entire row if cells in column D contain certain value
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-15-2012, 12:10 PM
  5. Delete entire row if certains cells are blank
    By ZH1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2011, 01:42 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