+ Reply to Thread
Results 1 to 7 of 7

Block if without end if?

  1. #1
    Registered User
    Join Date
    10-12-2010
    Location
    London, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    4

    Block if without end if?

    Please Login or Register  to view this content.
    Why does this keep telling me "block if without end if" when there clearly is an "end if"

    excel 2010 btw

    thanks
    Last edited by vonblart; 11-16-2010 at 02:10 PM. Reason: title change per request

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,053

    Re: I'm over looking a simple solution

    Please, rename your title according to the rules:

    Please read and adhere to these simple rules!

    1. Use concise, accurate thread titles. Your post title should describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change the title of the thread, click EDIT on the original post, then click the Go Advanced button, then change the title. If two or more hours have passed, the EDIT button will not appear, and you need to ask a moderator to change the title.
    Never use Merged Cells in Excel

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Block if without end if?

    This is just a guess, I can't work out your logic
    Please Login or Register  to view this content.

    Always use Option Explicit, and indent your code, it's more than half the battle when debugging.

    Hope this helps
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Registered User
    Join Date
    10-12-2010
    Location
    London, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Block if without end if?

    I knew it was simple. I needed to use "elseif" instead of "if" after the first occurrence of "if" and i formatted it in a more proper fashion as suggested. thanks!

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Block if without end if?

    So is this your answer?
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-12-2010
    Location
    London, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Block if without end if?

    Yes Marcol. Your first post resolved the error, but using elseif gave me the desired output from the macro. I'm new to VBA so tell me if this is this poor coding?

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Block if without end if?

    There is nothing wrong with that approach.
    I find Select more readable, that's just a personal thing
    Please Login or Register  to view this content.

    Remember

    Always use Option Explicit, and indent your code, it's more than half the battle when debugging.

    When naming your variables try to sensibly use upper and lower case in the name, this will make typos easy to detect, but only if you have Option Explicit set.

    This will stand you in good stead in the long run.

    Try this add-in for indenting it's far better than the standard indent, and used by many of the big boys (and gals) on this forum.

    http://www.oaltd.co.uk/Indenter/

    Hope this helps

+ 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