+ Reply to Thread
Results 1 to 13 of 13

Never ending loop

  1. #1
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35

    Never ending loop

    Hi, the followng code should execute once but it seems to just keep going round in a loop. I reckon it's probably a simple mistake that is staring me in the face, but I can't see the trees for the wood.

    Help appreciated!

    Please Login or Register  to view this content.
    Last edited by Andy Pope; 10-23-2008 at 04:20 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    As you are changing the worksheet you are causing the Change event to fire thus running though the code and the loop again.

    You need to disable events whilst processing your loop

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35
    Brilliant!
    Thanks for the help :o)

  4. #4
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35
    One other thing you may be able to help with...

    In the line:

    Please Login or Register  to view this content.
    It only seems to be comparing the DAY of the date, instead of the full date. How would I go about comparing the entire date?

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    I guess it would depend on the content of the cell.
    Have are the values in row 4?

  6. #6
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35
    They are in the format dd/mm/yyyy.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    Now includes a time in the date format.
    perhaps you should use DATE instead of NOW

  8. #8
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35
    Still appears to be comparing the day only.....?

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    post an workbook with a couple of example cells.
    with values less, equal and greater than test value

  10. #10
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35
    Here's a scaled down version...

    Thanks again by the way!
    Attached Files Attached Files

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    It's the transposing of UK/US date formats.

    try this revision to the top of your routine

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35
    Thanks for that Andy, much appreciated.

  13. #13
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35
    Can a Mod mark this as SOLVED please?

+ 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. Programming a Find Loop?
    By mcbain in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-21-2008, 04:44 AM
  2. Loop with a loop? or something else..
    By Aurbo99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2007, 09:56 PM
  3. Do Loop Until Loop
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-12-2007, 10:20 AM
  4. For type loop verse Do type loop
    By boylejob in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-09-2007, 03:02 PM
  5. Extend Loop From Within ?
    By Blewyn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-26-2007, 05:34 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