+ Reply to Thread
Results 1 to 11 of 11

Why is this Do Loop not working right?

  1. #1
    evilrtc
    Guest

    Why is this Do Loop not working right?

    The loop cycles through my sheet correctly but wont delete any cells. What's the deal?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Why is this Do Loop not working right?

    I'm not sure if you really want to delete cells or just clear the contents.

    I'll assume you want to clear the contents:

    This code test each cell from E2 through the last non-blank Col_E cell. If the cell's value is TRUE (the text TRUE, not the boolean value), the contents of the corresponding cell in Col_B are cleared.

    Please Login or Register  to view this content.
    Does that help?
    If not....what do you want your code to do?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    evilrtc
    Guest
    That is exactly what I want my code to do. Thank you so much! I'm grateful for you code but was just still curious why mine was not working.

    Thanks again!

  4. #4
    evilrtc
    Guest

    I tried this

    Please Login or Register  to view this content.
    I tried this variation of your code on a different section of what I'm working on. It only half works though. I use one purge routine to take out the contents of one column, then a second purge routine to take out a second column. If the two purge routines result in both columns being cleared then I have this third purge that just deletes the record entirely.

    However, its not deleting every record with two blank columns, even when they show "TRUE" in the G column. I'm not sure how to get it to do that. Thanks for everything by the way!

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Why is this Do Loop not working right?

    When deleting rows, you need to start from the BOTTOM....Otherwise, it's like cutting off the tree limb you're standing on.

    Try this:
    Please Login or Register  to view this content.
    Does that help?

  7. #7
    evilrtc
    Guest
    Didn't work unfortunately. Maybe it needs to be step 1 instead of step -1?

    Still learning a great deal sorry!

    I appreciate everyone's help here though. You guys are awesome!

  8. #8
    evilrtc
    Guest
    RoyUK's was the one I tried I will try the latest. Thanks again!

  9. #9
    evilrtc
    Guest
    My sheet contains 51000 records roughly. How long would this take to cycle all the way through. I let it run for two and a half hours and it was still going when I came back.

    How long should this take?

  10. #10
    Forum Contributor
    Join Date
    01-10-2006
    Location
    Ahmedabad, India
    MS-Off Ver
    Office 2000
    Posts
    346
    Quote Originally Posted by evilrtc
    My sheet contains 51000 records roughly. How long would this take to cycle all the way through. I let it run for two and a half hours and it was still going when I came back.

    How long should this take?
    A few seconds really. Is your Page break view on? Set it off.

    RoyUK's solution should work. What is the problem you are facing? What do you mean not working? The cell must contain only "TRUE" - no leading or lagging spaces. If you may have spaces use TRIM to remove the spaces. Modify one line to If TRIM(UCase(cCell.Value)) = "TRUE" Then
    A V Veerkar
    Last edited by avveerkar; 08-20-2007 at 03:22 PM.

  11. #11
    Registered User
    Join Date
    08-16-2007
    Posts
    4

    Do you have screen updating on?

    Remember to set:

    Please Login or Register  to view this content.
    I've seen that normally over 99% of the execution time is spent for screen updates.

    Quote Originally Posted by evilrtc
    My sheet contains 51000 records roughly. How long would this take to cycle all the way through. I let it run for two and a half hours and it was still going when I came back.

    How long should this take?

+ 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