+ Reply to Thread
Results 1 to 7 of 7

IF statement does not stop correctly

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    68

    IF statement does not stop correctly

    Hi all

    I was recently given the below code which seemed to work correctly, but unfortunately it does not stop when it comes to the field "lost clients". It carries on rather than stepping to the next piece of code. I have tried multiple times to fix this myself, but as usual failed. All help appreciated.
    Thank you

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 08-22-2013 at 07:45 AM. Reason: added code tags

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: IF statement does not stop correctly

    The code has 3 ifs statements. If the row is not "LOST CLIENTS" , it will go on and test the same row for not empty and so on.
    It may be you have upper case of "LOST CLIENTS" where the code will not find it if it is in lower case.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: IF statement does not stop correctly

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: IF statement does not stop correctly

    Hi, "LOST Clients" is in upper case in both

    cannot attached a file, as the system tells me it is to big??

  5. #5
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: IF statement does not stop correctly

    You say "unfortunately it does not stop when it comes to the field "lost clients", but nowhere in your code it tells to stop when that code is found - it only says that the value in column C shouldn't be changed, but not to stop the code...
    Try this :

    Please Login or Register  to view this content.
    I use the InStr method in case you have "invisible rubbish" or spaces in front or at the end of your cell...

    Please click the * below if this helps
    Please click the * below if this helps

  6. #6
    Registered User
    Join Date
    05-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: IF statement does not stop correctly

    Makes sense, now get Compile error on the first Else - saying "Else without If"

    Scrap that - works now
    Last edited by heathb; 08-22-2013 at 11:11 AM. Reason: comment not required

  7. #7
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: IF statement does not stop correctly

    Move the "Exit For" to the next line

    Also make sure the first "End If" is commented out, like in the example posted above

+ 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. If Or Statement not functioning correctly
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2012, 08:08 PM
  2. Why isn't this if statement functioning correctly?!?
    By rmar2011 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-29-2011, 07:31 AM
  3. If statement not adding up correctly
    By sted999 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-19-2010, 10:54 AM
  4. Replies: 0
    Last Post: 05-17-2005, 05:49 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