+ Reply to Thread
Results 1 to 6 of 6

Compiler Error on End Sub in If stmt

  1. #1
    Registered User
    Join Date
    08-20-2014
    Location
    Denver, Colorado
    MS-Off Ver
    2010
    Posts
    18

    Angry Compiler Error on End Sub in If stmt

    Hello,

    I'm getting a Compiler error "Block If without End If". The thing is, I have my End If in. It's erroring when I try to Exit Sub when the If condition isn't met. Suggestions? Subroutine with offending line marked in comments line with /*************************** below:
    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: Compiler Error on End Sub in If stmt

    you cant have an ELSE after END IF

    'Compiler error Block If without End if
    '/***************************************************************
    End Sub
    End If

    Else

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Compiler Error on End Sub in If stmt

    I think you're going to have to review the other if statements as well.

  4. #4
    Registered User
    Join Date
    08-20-2014
    Location
    Denver, Colorado
    MS-Off Ver
    2010
    Posts
    18

    Re: Compiler Error on End Sub in If stmt

    Thanks, I've had too much coffee!

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Compiler Error on End Sub in If stmt

    You can't use End Sub in the middle of a sub, if you want to exit the sub use Exit Sub.
    Last edited by Norie; 08-26-2014 at 03:37 PM.
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    08-20-2014
    Location
    Denver, Colorado
    MS-Off Ver
    2010
    Posts
    18

    Re: Compiler Error on End Sub in If stmt

    Thanks Norie!

+ 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. VBA Compiler error- Excel 2010
    By kt090678 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-07-2014, 09:10 AM
  2. [SOLVED] Compiler Error: Object Required
    By RGrunden in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-24-2012, 09:13 PM
  3. Compiler error: Method or data member not found
    By sathikbabu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2011, 02:51 AM
  4. Compiler Error
    By vba-lover in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-15-2007, 10:22 PM
  5. [SOLVED] Help with compiler error
    By Pank Mehta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2005, 08:06 AM

Tags for this Thread

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