I am trying to write a function that can search an Range of cells in a separate sheet and if there is a match I want to set the cell to the value in the same row but the first column of Range. The first column is initials, the other columns in the range will only be integers. I am writing the function in VBA. So far I can't get my function to even match the a value that is there.
My script:
Public Function searchRange(val As Range, sRng As Range)
Dim cel As Range
For Each cel In sRng.Cells
If cel.value = val.value Then
searchRange = "found!"
Else
searchRange = "not found!"
End If
Next cel
End Function