+ Reply to Thread
Results 1 to 5 of 5

search for combined time and date

  1. #1
    Registered User
    Join Date
    11-18-2017
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    2

    search for combined time and date

    Hi

    i need to search for a combined specific time and date value in a single column, as shown:
    28-02-2018 17:00
    28-02-2018 18:00
    28-02-2018 19:00
    28-02-2018 20:00
    28-02-2018 21:00
    etc

    if i omit the time, I can search for a day, without issue using :

    d = DateSerial(Year(cd), Month(cd), Day(cd))
    Set r = Cells.Find(What:=d, LookIn:=xlValues, LookAt:=xlWhole, After:=Range("a1"))

    but cannot successfuly include a time aspect (d + TimeSerial(Hour(d), Minute(d), 0) - the search just fails to find anything. I am presuming this type of search must be a relatively common need: appeciate if anyone can point me to a method that can work.

    thanks..

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: search for combined time and date

    The .Find method is a text based search. Format your search for date-time the same as the displayed date-times in the column

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    11-18-2017
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    2

    Re: search for combined time and date

    thanks for your idea, but that still didn't work for me - so I changed your code to refer specificially search one of the cells in the column

    Set r = Cells.Find(What:=Format(Range("A10"), "dd-mm-yy hh:mm"), LookIn:=xlValues, LookAt:=xlWhole, After:=Range("a1"))

    and it still wouldn't find it.


    I can do a simple "find" in Excel (not using VBA) and it will find the correct date/time entry in the column. If I record the process and run that - it doesnt find it ???????

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,595

    Re: search for combined time and date

    Just try change to
    Please Login or Register  to view this content.
    and see if it works.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: search for combined time and date

    Try this...

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Split combined date and time data into separate fields
    By Halfcent in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-27-2016, 05:27 AM
  2. search code-date then copy name-date-time to another sheet
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2013, 02:25 AM
  3. [SOLVED] Challenging search (Combined V & HLOOKUP?)
    By mrmyr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-20-2012, 07:36 AM
  4. Custom format, combined date, time and letter
    By bugmenot in forum Excel General
    Replies: 3
    Last Post: 12-15-2008, 05:09 AM
  5. Easiest way to pull value using Date & Time combined
    By mystic342005 in forum Excel General
    Replies: 4
    Last Post: 07-03-2007, 10:28 PM
  6. Replies: 0
    Last Post: 08-28-2005, 10:35 AM
  7. [SOLVED] Creating a Combined Date/Time Shortcut
    By Michael Link in forum Excel General
    Replies: 7
    Last Post: 02-14-2005, 09:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1