+ Reply to Thread
Results 1 to 10 of 10

speedup the code for deleting rows

  1. #1
    Registered User
    Join Date
    01-05-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2003
    Posts
    22

    speedup the code for deleting rows

    Hi,
    I have this code which is supposed to delete rows containing "0" and "null" in all worksheets.
    But this is taking too much time and seems like system is gonna hang.

    Is there anything we can do to speed up code. Also, its "search all worksheet" function is not working, and is doing work in just the active worksheet.
    Please help.

    Please Login or Register  to view this content.
    Last edited by maheshwow; 01-17-2012 at 02:46 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: speedup the code for deleting rows

    Use this:

    Please Login or Register  to view this content.
    Regards,
    Khaled Elshaer
    www.BIMcentre.com

    Remember To Do the Following....
    1. Thank those who have helped you by clicking the Star below their post.
    2. Mark your post SOLVED if it has been answered satisfactorily:
    • Select Thread Tools (on top of your 1st post)
    • Select Mark this thread as Solved

  3. #3
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: speedup the code for deleting rows

    If you can avoid using a loop, it may generally be faster. Without your workbook, I can only guess if this would work, but try code such as the following:

    Please Login or Register  to view this content.
    Let me know if this works.

  4. #4
    Registered User
    Join Date
    01-05-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: speedup the code for deleting rows

    Thankyou for immediate response,

    I've put both codes in the attached sample workbook,
    Mr.Kelshaer's code worked well, but was not applying to whole workbook. It is running only in active sheet.
    Mr.BigBas code worked on all sheets, but deleted all rows. i couldn't understand "A1" & "A2" used in this code, hence could not modify it.
    I'll working on workbook similar to attached one, please help me me with updated code.

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: speedup the code for deleting rows

    Sorry, I used you code in my previous post.
    Please try this:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: speedup the code for deleting rows

    Based on your workbook structure, I'd go with Kelshaer's method. Whenever possible, you want to avoid using multiple loops in workbooks when built-in excel commands work, but in your case, with the data setup as it is, it's more difficult to use the filter/delete method. Fortunately, the workbook as posted is not so large as to be resource intensive.

  7. #7
    Registered User
    Join Date
    01-05-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: speedup the code for deleting rows

    Thanks again, but i'm getting "object does not support this property or method" error. Snapshot & updated excel sample attached.
    sample2.jpg

    please take look at attachments..

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: speedup the code for deleting rows

    I don't know why it is giving you an error while it works with me.
    any way I've changed the code a little bit. please try this and let me know

    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: speedup the code for deleting rows

    In mahesh's sample, the following line is incorrect:

    Please Login or Register  to view this content.
    Mahesh, you only included
    Please Login or Register  to view this content.
    You must include the .Worksheets

  10. #10
    Registered User
    Join Date
    01-05-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: speedup the code for deleting rows

    Thankyou very much. This one worked.. even though its giving strange row height in next to last row. But i'm not concerned abt formatting.
    I really appreciate your help.!!


    Now i know i've taken too much of your time, but If you can spare little more, please look at my post for "merging worksheet with forced repetition" http://www.excelforum.com/excel-prog...99#post2684299. Could be of tremendous help for me.

    This has remained unanswered even after multiple requests..... pls just let me know it its not possible with vba.

+ 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