+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 : Compile Error: Block if without end if, when I add a end if it says end if without...

  1. #1
    Registered User
    Join Date
    08-08-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2007
    Posts
    10

    Unhappy Compile Error: Block if without end if, when I add a end if it says end if without...

    Block if.
    It stinks. I had this problem for days now, and when someone adds a suggestion it does not work. If you can, please hurry, I'm operating on a deadline...
    Please Login or Register  to view this content.

    When I add the end if like a suggestion said, I get
    Please Login or Register  to view this content.
    I get end if without block if problem. Please help, anyone.

    BTW, the point of this macro is to display all the info in an xml file into one sheet. Please tell me if I am doing anything else wrong.
    Thank you
    Last edited by F1lm1; 08-10-2011 at 12:33 PM. Reason: Makes change more clear

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Compile Error: Block if without end if, when I add a end if it says end if withou

    Please Login or Register  to view this content.
    See the problem?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-08-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Compile Error: Block if without end if, when I add a end if it says end if withou

    Code:

    If nde1.HasChildNodes Then
    For Each nde2 In nde1.ChildNodes
    'Set nde3 = nde2.parentNode
    End If
    Next

    See the problem?
    TBH, not really.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Compile Error: Block if without end if, when I add a end if it says end if withou

    What line does the End If pair with?

    What line does the Next pair with?

  5. #5
    Registered User
    Join Date
    08-08-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Compile Error: Block if without end if, when I add a end if it says end if withou

    At the risk of sounding stupid, what does next pair with?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Compile Error: Block if without end if, when I add a end if it says end if withou

    The Next goes with the For Each, the End If goes with the If. They have to be nested in pairs; they are in the wrong order.

    I was assuming that you had written this code.

  7. #7
    Registered User
    Join Date
    08-08-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Compile Error: Block if without end if, when I add a end if it says end if withou

    Ok. I will try.
    BTW, yes I wrote it

  8. #8
    Registered User
    Join Date
    08-08-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Compile Error: Block if without end if, when I add a end if it says end if withou

    Alright. Okay, I rearranged them, and it seemed to work, but I got a problem on a different topic (in excel).
    My code currently is
    Please Login or Register  to view this content.
    And it said object variable or with block variable not set. Any ideas?

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Compile Error: Block if without end if, when I add a end if it says end if withou

    Can't help with that one, other than observing that you never initialized nde1, but please start a new thread for the new topic.

+ 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