A problem with Range().Find(timeValue),it's so weird.

Jinspet

New Member
Joined
Mar 10, 2009
Messages
13
I have a column of data,they r time value. The range format is "hh:mm:ss".:confused:
Here is my column A:
11:59:13
12:35:00
12:59:23
13:00:00
13:34:20
16:24:09
My VBA code is:
'-------------------------------------
sub Test()
Dim x As Range
Set x = Range("a1").EntireColumn.Find(What:="12:59", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
MsgBox x.Address​
end sub
'-------------------------------------
when the argument "What" is bigger than "13:00" then the Find() will not working ,runtime error. Any suggestions ?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Maybe you can use:

Code:
Sub Test()
    Dim i As Long
    i = Application.Match(CDbl(TimeValue("13:00")), Range("A:A"))
    MsgBox Cells(i, 1).Address
End Sub
 
Upvote 0
thanks a lot
your way is very good.
and i just solved my problem :
Range("a1").EntireColum.Find("13:00",Lookin:=xlValue) ,it works now,but thank you any way for replying my first post here.:LOL:
 
Upvote 0

Forum statistics

Threads
1,203,356
Messages
6,054,927
Members
444,759
Latest member
TeckTeck

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top