Hello guys. This is my first post although I have been visiting this site almost daily lately. So first of, thanks everyone for the great insight.
Here is my question. In an excel column B, i have dates ("Custom" as per Excel) presented as such:
time starting 9:15
5/6/2010 11:00:00 AM
5/6/2010 11:15:00 AM
5/6/2010 11:30:00 AM
5/6/2010 11:45:00 AM
5/6/2010 12:00:00 PM
5/6/2010 12:15:00 AM
5/6/2010 12:30:00 AM
5/6/2010 12:45:00 AM
5/6/2010 13:00:00 PM
5/6/2010 13:15:00 AM
5/6/2010 13:30:00 AM
5/6/2010 13:45:00 AM
5/6/2010 14:00:00 PM
time ending 16:15
Each time actually repeats itself many times before moving to the next 15min block.
I am using a the Find function to return the row of the first time a certain time is encountered in my column. For instance
Dim TimeSection As Long
Range("B1").Select
TimeSection = CalcSheet.Columns(2).Find(What:=Time, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row
"Time" is a date type, and is expressed as a 12h format. It is obtained from using Timevalue() on another variable.
.Find returns the right result for most time, but not for certain. For example, if Time is 2:15pm, it will not return the row where 14:00 is. It will find 12:15 instead, as it doesnt care about the "1" in front of the "2:15". The same happens with 13:30 (1:30pm) for instance, which will be read as 11:30am. I undertand Find finds the first occurence of the searched item, which is great, but this seems weird since dates/times are serial numbers.
I have been trying to use Time as a string instead, using converting whatever time variable in need to find with FormatDateTime(___, vbShortTime), however the find function doesn't recognize the string as my cells are dates.
I have been using Find to gain speed as I have to perform the search many times on thousands of workbooks, until I realized it skipped all the 13:00 -14:00 time range.
Is the answer to use something else other than Find?
Any help appreciated!
Greg
Here is my question. In an excel column B, i have dates ("Custom" as per Excel) presented as such:
time starting 9:15
5/6/2010 11:00:00 AM
5/6/2010 11:15:00 AM
5/6/2010 11:30:00 AM
5/6/2010 11:45:00 AM
5/6/2010 12:00:00 PM
5/6/2010 12:15:00 AM
5/6/2010 12:30:00 AM
5/6/2010 12:45:00 AM
5/6/2010 13:00:00 PM
5/6/2010 13:15:00 AM
5/6/2010 13:30:00 AM
5/6/2010 13:45:00 AM
5/6/2010 14:00:00 PM
time ending 16:15
Each time actually repeats itself many times before moving to the next 15min block.
I am using a the Find function to return the row of the first time a certain time is encountered in my column. For instance
Dim TimeSection As Long
Range("B1").Select
TimeSection = CalcSheet.Columns(2).Find(What:=Time, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row
"Time" is a date type, and is expressed as a 12h format. It is obtained from using Timevalue() on another variable.
.Find returns the right result for most time, but not for certain. For example, if Time is 2:15pm, it will not return the row where 14:00 is. It will find 12:15 instead, as it doesnt care about the "1" in front of the "2:15". The same happens with 13:30 (1:30pm) for instance, which will be read as 11:30am. I undertand Find finds the first occurence of the searched item, which is great, but this seems weird since dates/times are serial numbers.
I have been trying to use Time as a string instead, using converting whatever time variable in need to find with FormatDateTime(___, vbShortTime), however the find function doesn't recognize the string as my cells are dates.
I have been using Find to gain speed as I have to perform the search many times on thousands of workbooks, until I realized it skipped all the 13:00 -14:00 time range.
Is the answer to use something else other than Find?
Any help appreciated!
Greg