Hi folks,
I have a loop tests to see if a cell matches a value within an array. The code is as follows:
In order to save time, I would like the loop to quit as soon it finds a match so I would like to put a "next" where I have it marked in the comment. That is to say, "Once you have found a match, go on to the next cell". If I were to put a "next" there, I get the error "Next without For". Any ideas?
-Ilya
I have a loop tests to see if a cell matches a value within an array. The code is as follows:
Code:
Function MultiCalc(MyArray As String, MyRange As Range, Cnt As Integer)
Dim MyCell As Range
For Each MyCell In MyRange
MyText= MyCell.Text
For n = 1 To Cnt
If MyArray(n) = MyText Then
MultiCalc = True ' "Next" here
End If
Next
End Function
In order to save time, I would like the loop to quit as soon it finds a match so I would like to put a "next" where I have it marked in the comment. That is to say, "Once you have found a match, go on to the next cell". If I were to put a "next" there, I get the error "Next without For". Any ideas?
-Ilya