+ Reply to Thread
Results 1 to 2 of 2

Nested Loops and Exit For Statement

Hybrid View

  1. #1
    Registered User
    Join Date
    04-22-2012
    Location
    Syracuse, NY, USA
    MS-Off Ver
    Office 365
    Posts
    61

    Nested Loops and Exit For Statement

    The code I'm writing looks something like this
    Dim ws As Worksheet
    Dim cRange1 As Range
    Dim cRange2 As Range
    Set ws=Worksheets("Test")
    For Each cRange1 In ws.Range("A1:J10")
       For Each cRange2 In ws.Range("A1:A10")
          If cRange2.Value=WorksheetFunction.SMALL("A1:A10",1) Then
             Exit For
          End If
       Next cRange2
    Next cRange1
    Will that Exit For statement inside the cRange2 Loop cause just the cRange2 loop to terminate or both loops to terminate?
    Reality is stranger than fiction.

  2. #2
    Registered User
    Join Date
    08-30-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Nested Loops and Exit For Statement

    It will cause only cRange2 loop to terminate.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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