+ Reply to Thread
Results 1 to 3 of 3

Trouble matching statements in VBA

  1. #1
    Forum Contributor
    Join Date
    11-14-2009
    Location
    Midwest
    MS-Off Ver
    Excel 2003/2007
    Posts
    103

    Trouble matching statements in VBA

    Hey all,
    I am working on a macro that I can't seem to get to work, seems like something very basic, but I keep getting errors that my End With doesn't have a With, but it does. I read that it can happen because of an unended If statement within the With, but my if statement is matched. Here is that section of code:
    Please Login or Register  to view this content.
    I see no problem, but I am a rookie and obviously there is one. Anyone see what I'm doing wrong?
    Last edited by bibleguy125; 02-14-2012 at 01:24 PM.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Trouble matching statements in VBA

    Block instructions, such as loops, with statements and Ifs are nested and must be closed in the reverse order of opening (i.e. first opened=last closed)

    You're getting an error at your End With because you haven't closed your Do Until loop

    If you put a 'Loop' on the line between the End If and the End With all should be well.

  3. #3
    Forum Contributor
    Join Date
    11-14-2009
    Location
    Midwest
    MS-Off Ver
    Excel 2003/2007
    Posts
    103

    Re: Trouble matching statements in VBA

    Oh, I guess I didn't realize a Do needed to be ended. Thanks, I knew I was missing something simple.

+ 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