View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Find only in visible cells....

If you had used Range("A:A"), it would have worked.

Anyway, this changed version should work:

Function FindRecord(id As String, Col As Range) As Long
Dim i As Long
i = 0
If Col.Count = 1 Then
Set Col = Col.Cells
End If
Set rng = Col.Find(what:=id, _
After:=Col(Col.Count), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then _
i = rng.Row
FindRecord = i
End Function

--
Regards,
Tom Ogilvy

"Mike Iacovou" wrote in message
...
thanks as ever Tom. I get a type mismatch on this line:
set rng = Col.Find(what:=id, _
After:=col(col.count), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
id is a string,col would have been columns("A:A") for example... TIA