+ Reply to Thread
Results 1 to 14 of 14

Delete a row when cell value equals zero macro

  1. #1
    Registered User
    Join Date
    09-03-2012
    Location
    cairo, egypt
    MS-Off Ver
    Excel 2010
    Posts
    6

    Delete a row when cell value equals zero macro

    hi all ,
    i have and excel sheet which is a compilation of various sheets copied from different sources . i want to delete the rows where their cells in column e equals zero starting from e3 as e2 has a zero value i want to keep.
    the sheet that contains that column is named "all data"
    thanks a lot and best regards,

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,136

    Re: Delete a row when cell value equals zero macro

    hi massedamha, welcome to the forum. try this:
    Please Login or Register  to view this content.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    09-03-2012
    Location
    cairo, egypt
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Delete a row when cell value equals zero macro

    Thnx for the welcome :D
    It worked thanks a lot.
    Last edited by jeffreybrown; 11-17-2012 at 11:03 AM. Reason: Removed quote...just causes clutter.

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    13,764

    Re: Delete a row when cell value equals zero macro

    It would be nice, if you told us, you already posted you question somewhere else (crossposting).

    http://www.mrexcel.com/forum/excel-q...ero-macro.html

    and here is a link, why people find crossposting annoying.

    http://www.excelguru.ca/content.php?184
    Last edited by oeldere; 11-17-2012 at 08:57 AM. Reason: added: and her is a link, etc etc
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  5. #5
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,417

    Re: Delete a row when cell value equals zero macro

    @benishiryo, just a head's up, you usually don't need to use select:
    Please Login or Register  to view this content.
    is the same as:
    Please Login or Register  to view this content.
    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  6. #6
    Registered User
    Join Date
    09-03-2012
    Location
    cairo, egypt
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Delete a row when cell value equals zero macro

    sorry about cross posting i really didn't mean to make any one upset i will read the rules next time . sorry once again and thanks for the help alot.

  7. #7
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,417

    Re: Delete a row when cell value equals zero macro

    Hi @massedamha,

    Cross-posting is generally looked down upon in forums. If you post in one forum and don't get an answer then you can 'bump' the thread a couple times. If no response then you can ask the same question in another forum but make sure to post links to the both forums. People just don't want to waste their time working on a solution that you may have already found on another site. Also if you do get answer at another site then please share it in our original thread so that other can gain from the solution.

    In the end, we all make mistakes and the important thing is to learn from them.

    Good luck.

    abousetta

  8. #8
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,417

    Re: Delete a row when cell value equals zero macro

    On second thought, @benishiryo's code can be reduced to this:

    Please Login or Register  to view this content.
    abousetta

  9. #9
    Valued Forum Contributor HSV's Avatar
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003 / 2007
    Posts
    753

    Re: Delete a row when cell value equals zero macro

    Without a loop.
    Please Login or Register  to view this content.
    Or:
    Please Login or Register  to view this content.
    Last edited by HSV; 11-17-2012 at 12:00 PM. Reason: Or:
    Kind regards, Harry.

  10. #10
    Registered User
    Join Date
    09-03-2012
    Location
    cairo, egypt
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Delete a row when cell value equals zero macro

    Thnx HSV but i tried both codes it didnt work dunno y

  11. #11
    Valued Forum Contributor HSV's Avatar
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003 / 2007
    Posts
    753

    Re: Delete a row when cell value equals zero macro

    Hi massedamha,

    Here is a example to show you it works fine.
    The filter is much faster then a loop, especially when it comes to multiple rows with a zero.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    09-03-2012
    Location
    cairo, egypt
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Delete a row when cell value equals zero macro

    HI HSV
    Actually i tried yours again found out i had to change the cell format from custom(0,0) to number(#,##0) after that i inserted the code and it worked great and really fast.
    thanks a lot for the help.
    i really appreciate it.
    Quote Originally Posted by HSV View Post
    Hi massedamha,

    Here is a example to show you it works fine.
    The filter is much faster then a loop, especially when it comes to multiple rows with a zero.

  13. #13
    Valued Forum Contributor HSV's Avatar
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003 / 2007
    Posts
    753

    Re: Delete a row when cell value equals zero macro

    Hi massedamha,

    I'm glad it works fine to you too.
    You can also customize the code of course.
    Please Login or Register  to view this content.
    Try it once.

  14. #14
    Registered User
    Join Date
    09-03-2012
    Location
    cairo, egypt
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Delete a row when cell value equals zero macro

    Thanks
    actually i needed to change to format as it showed number with one digit as (0#) which looked weird.
    Quote Originally Posted by HSV View Post
    Hi massedamha,

    I'm glad it works fine to you too.
    You can also customize the code of course.
    Please Login or Register  to view this content.
    Try it once.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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