You can exit from a For/Next loop by using the Exit For statement. The following example searches the Global array names for the name "Fred". If it finds the name, it returns the index of the name in the array. Otherwise it returns -1. For example, if the names array is:
Array ("Frank", "Helen", "Fred", "Linda")
Then the formula returns 3.
Global names () As String 'The names array has been initialized and filled 'in other formulas Dim i formula = -1 'The UBound function returns the size of its array 'argument For i = 1 to UBound (names) If names (i) = "Fred" Then formula = i Exit For End If Next I