+ Reply to Thread
Results 1 to 6 of 6

Nested IF Statement not working

  1. #1
    Registered User
    Join Date
    07-22-2021
    Location
    Portsmouth, England
    MS-Off Ver
    Microsoft Home and Business 2019
    Posts
    6

    Nested IF Statement not working

    Hi, I have written what I thought was a fairly simple nested IF statement that is not working and I can't work out why. When I try to run it, I get an "Else without If" error message. If I comment out the nested "End If"'s (eg line 13) then it executes but not as intended - if that first If statement evaluates as "N", the code goes to the first nested ElseIf (line 5) rather than the unnested ElseIf (line 14). There is probably something really obvious but I can't see it!

    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Nested IF Statement not working

    I'd be inclined to think that all the ElseIfs should be just Ifs.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-22-2021
    Location
    Portsmouth, England
    MS-Off Ver
    Microsoft Home and Business 2019
    Posts
    6

    Re: Nested IF Statement not working

    Oh, of course I don't want them to be elseif anyway, I want them all to be individual if statements.

    Thanks!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Nested IF Statement not working

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  5. #5
    Registered User
    Join Date
    07-22-2021
    Location
    Portsmouth, England
    MS-Off Ver
    Microsoft Home and Business 2019
    Posts
    6

    Re: Nested IF Statement not working

    Done and done!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Nested IF Statement not working

    Thank you

+ 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. [SOLVED] Nested IF(OR(AND statement not working on all rows
    By billrogers184 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-25-2021, 12:20 PM
  2. [SOLVED] Nested IF statement not working
    By bibu in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-26-2015, 01:26 PM
  3. [SOLVED] Nested if statement not working
    By bryden2008 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-27-2015, 09:15 PM
  4. [SOLVED] Nested IF statement not working
    By Markjoyous in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-11-2014, 12:25 PM
  5. [SOLVED] Nested if statement not working
    By crsport3 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-08-2014, 07:12 PM
  6. [SOLVED] Nested If statement not working
    By hornet7 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-08-2013, 01:31 PM
  7. nested IF statement not working
    By piquet2759 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-13-2009, 07:03 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