Function ValueFinder(min As Double, N As Integer, colsave As Long) As Long

Dim results As Range 'the cell where min is first found
Dim x As Long 'the row coordinate of the cell with min

Set results = Cells.Find(what:=min, after:=Cells(ROW_DATASTART - 1, colsave), searchorder:=xlByRows, searchdirection:=xlNext) 'find the cell with value of min

x = results.row

ValueFinder = x 'equates function output to row of results

End Function


heres my function, min, N and colsave are all from a seperate sub and they are all calculated correctly. I always get an error when it reaches the part where it says: x = results.row

i looked back and saw that when i hover over "results" while vba is already on x = results.row, results says nothing...

this is giving me a headache

thanks so much for helping so far, this forum has been great!