What is the correct syntax to search and select time values that are in time format?

WINTER_007

New Member
Joined
Dec 25, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello, pretty new, not to excel but to tinkering at the vba level.

I am trying to do a simple search, select, copy, past on specific times and am hung up at an ultra-basic level.

I can do it if I wiggle around and make time become text and then filter/search by doing this: If Worksheets("Sheet1").Cells(I, 1).Value = "10:00 AM" or

But I have not figured out how to capture it if it is still in time format. It does not work if I put it in quotes like text and it does not work if I just put the value there with no quotes.

What is the right way/syntax to do that.?

Thank you for a pointer here.

Winter
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Maybe something like
VBA Code:
Sub FindTime()
    With Range("A2:A9")
        .Find(TimeValue("10:00 AM"), .Cells(.Cells.Count), xlFormulas, , , xlNext).Copy Range("C2")
    End With
End Sub
Book3
A
1
208:00
309:00
410:00
511:00
612:00
713:00
814:00
915:00
Sheet3
 
Upvote 0
Maybe something like
VBA Code:
Sub FindTime()
    With Range("A2:A9")
        .Find(TimeValue("10:00 AM"), .Cells(.Cells.Count), xlFormulas, , , xlNext).Copy Range("C2")
    End With

[/QUOTE]
I need to tinker with that later, but I see your reference to "find(timevalue.....) and see that that is an area that I want to study up a bit. Did a quick google and saw some good content for later.

Thank you kindly.
 
Upvote 0
Maybe something like
VBA Code:
Sub FindTime()
    With Range("A2:A9")
        .Find(TimeValue("10:00 AM"), .Cells(.Cells.Count), xlFormulas, , , xlNext).Copy Range("C2")
    End With
End Sub
Book3
A
1
208:00
309:00
410:00
511:00
612:00
713:00
814:00
915:00
Sheet3

Thank you kindly. I will tinker with it later and I see your reference to the "find timevalue" and will google a bit to get smarter on that.
 
Upvote 0
Thank you. That works.

How would I structure the syntax for minutes. So, if for example, it were a search for 10:15 AM rather than 10:00?

Thank you. That works.

How would I structure the syntax for minutes. So, if for example, it were a search for 10:15 AM rather than 10:00?
hour/24+minute/1440+second/3600
 
Upvote 0

Forum statistics

Threads
1,214,431
Messages
6,119,462
Members
448,899
Latest member
maplemeadows

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