title: Exit Function Not Working - VBA
body: <p>I am trying to exit the function if either the value is equal to the value I'm looking for, or if the row is equal to the row I'm looking for.</p>
  
  <p>But every time I use <code>Exit Function</code>, it doesn't work. And if I replace it with <code>End Function</code> it tells me that I don't have an End to my If statement. And I'm getting lost. </p>
  
  <pre><code>Function recursion(whereItEnds As Integer, lookingFor As Variant, currentMarker As Range, I As Integer, wsEverything As Worksheet) As Integer
      Dim col As Integer
      Dim newMarker As String
      newMarker = currentMarker.Value
      Dim currentMarker1 As Range
      recursion = 2
      col = 2
      If (StrComp(lookingFor, newMarker, vbTextCompare) = 0) Then
          Exit Function
      End If
  
      While (IsEmpty(wsEverything.Cells(col, "B").Value) = False)
          If (StrComp(wsEverything.Cells(col, "B").Value, newMarker, vbTextCompare) = 0) Then
              wsEverything.Cells.Range("A" &amp; col, "F" &amp; col).Copy
              Worksheets("Review").Cells.Range("A" &amp; I).PasteSpecial
              Worksheets("Review").Cells.Range("G" &amp; I).Value = col
              I = I + 1
              Set currentMarker1 = wsEverything.Cells(col, "E")
  
              If (col = whereItEnds) Then
                  Exit Function
              End If
              recursion = recursion(whereItEnds, lookingFor, currentMarker1, I, wsEverything)
          End If
          col = col + 1
      Wend
  End Function
  </code></pre>
  
  <p>I'm almost completely out of ideas as to why neither works.</p>
  
  <p>EDIT: It hits the if statements, it goes into those codes. but when debugging, it touches "exit function" but then it just keeps going. i just want it to end the statement. This is pulling data off another long sheet and putting it on a second sheet. it is checking for child parent circular errors. where a parent in the future is dependent on the child that originally was dependent on it. </p>