Option Base 1
Function pullphrase(txt As String, srch1 As String, Optional srch2 As String, Optional srch3 As String, Optional srch4 As String, Optional srch5 As String) As String
Dim i As Integer, myVals As Variant
Dim j As Integer, z As Integer
myVals = Array(srch1, srch2, srch3, srch4, srch5)
For i = LBound(myVals) To UBound(myVals)
If myVals(i) = "" Then Exit For
Next i
i = i - 1 'this excludes all blank variables from the code
For j = 1 To i
For z = 1 To Len(txt)
If Mid(txt, z, Len(myVals(j))) = myVals(j) Then Exit For
Next z
If z < Len(txt) Then
pullphrase = myVals(j)
End If
Next j
End Function