ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find Question (https://www.excelbanter.com/excel-programming/429781-find-question.html)

RaY

Find Question
 
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



Gary''s Student

Find Question
 
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

--
Gary''s Student - gsnu200856


"Ray" wrote:

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




All times are GMT +1. The time now is 07:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com