+ Reply to Thread
Results 1 to 6 of 6

"End If Without Block If"

  1. #1
    Registered User
    Join Date
    09-12-2016
    Location
    England, UK
    MS-Off Ver
    MS 365
    Posts
    59

    "End If Without Block If"

    Hi All,

    I am trying to set a vba code to revert to a single layout when closing a workbook. I have the code below, however it is returnng a compile error: "Block If without End If" on the last End If row (I have bold the row).

    I dont pretend to be amazing at VBA but I know my way around some basic code, but can someone please explain why I am getting this error and how to avoid it in future?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: "End If Without Block If"

    Perhaps:-
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: "End If Without Block If"

    If you indent the code correctly, the mismatched control structures are easy to see..
    Please Login or Register  to view this content.
    The error will usually be the inner most mismatched items.

    There are plenty of free indenting utilities available.
    Last edited by cytop; 09-29-2016 at 06:49 AM.

  4. #4
    Registered User
    Join Date
    09-12-2016
    Location
    England, UK
    MS-Off Ver
    MS 365
    Posts
    59

    Re: "End If Without Block If"

    Thank you both, is this simply due to the wrong way I have laid this out? I have tried the following formula which works. Thank you so much, noth of you!

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: "End If Without Block If"

    Still not indented correctly - get a copy of Smart Indenter (Free)

  6. #6
    Registered User
    Join Date
    09-12-2016
    Location
    England, UK
    MS-Off Ver
    MS 365
    Posts
    59

    Re: "End If Without Block If"

    Thank you I will try that out. Thank you both again.

+ 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. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  2. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  3. Replies: 1
    Last Post: 01-09-2013, 03:41 PM
  4. Error msgs: "Object varible or with block variable not set"; "subscript out of range"
    By menyanthe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-26-2009, 04:58 PM
  5. To block "to "eliminate" of the picture of form, information
    By Isaac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2006, 12:55 PM
  6. To block "to "eliminate" of the picture of form, information
    By Isaac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-29-2006, 12:35 PM
  7. To block "to "eliminate" of the picture of form, information
    By Isaac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-29-2006, 11:30 AM
  8. Return a block of text based on a single "short name" entry
    By cindee in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-05-2005, 04:05 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