I created a function within Excel VBA called FindNext(). When I enter "=FindNext()" into each individual cell, I get the desired results. However, if I enter "=FindNext()" into one cell and then drag the formula down a column, the column is populated with the first correct result, all the way down. By that I mean, if FindNext() returns a "7" in row 1, I will get a column full of "7s". However, if I manually paste the formula into each row, I'll get "7", "25", "32", whatever. I put a "DoEvents" in my code thinking that it just needs time to refresh but this did not fix the problem. Does anybody know what could be the issue? My code is below:
Kelly
Code:
Function FindNext() As String
If Cells(ActiveCell.Row, "N") <> Empty Then
FindNext = Cells(ActiveCell.Row, "N")
Exit Function
End If
r = ActiveCell.Row + 1
Do While Cells(r, "N").Value = Empty
r = r + 1
Loop
FindNext = Cells(r, "N").Value
DoEvents
End Function
Kelly