Find Question

R

Ray

I've tried using the following code to find a time stamp

Cells.Find(What:="21:30:00", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate

Which works to find the time 21:30:00. But the following does not work

Dim TimeMatch As Date
TimeMatch = Range("K6").Value
Cells.Find(What:=TimeMatch, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate

Can anyone tell me why or what I'm doing wrong.

Thanks,
-Ray
 
G

Gary''s Student

How about:

Sub LostandFound()
Dim TimeMatch As String
TimeMatch = Range("K6").Text

Cells.Find(What:=TimeMatch, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top