+ Reply to Thread
Results 1 to 2 of 2

[SOLVED] Excel Time issue

Hybrid View

  1. #1
    John
    Guest

    [SOLVED] Excel Time issue


    Can anyone help please, I have a time line created with the code below
    (where d3=0), so the time increments by 30 minutes and is displayed on the
    worksheet formted as time

    e.g.

    0:30
    1:00
    1:30
    2:00 etc etc

    objExcel.Cells(4, 4).Formula = "=$D3+time(0,30,0)"

    With objExcel
    Set objRange1 = .Cells(4, 4)
    Set objRange2 = .Range(.Cells(4, 4), .Cells(LastRow, 4))
    End With

    objRange1.AutoFill objRange2

    then I retrieve start and end times from a database, I want to search the
    sheet for the times, but because there is a mismatch between string and time
    i do not get any results with c and d both being set to nothing, how to i
    resolve this to get a match ?? x would equal "09:30" for example


    x = Trim(rs.Fields("Start Time"))
    y = Trim(rs.Fields("End Time"))

    With Worksheets(2).Range("d1:d52")
    Set c = .Find(x, LookIn:=xlValues)
    Set d = .Find(y, LookIn:=xlValues)
    End With



  2. #2
    Tom Ogilvy
    Guest

    Re: Excel Time issue

    With Worksheets(2).Range("d1:d52")
    Set c = .Find(cdbl(cdate(x)), LookIn:=xlValues)
    Set d = .Find(cdbl(cdate(y)), LookIn:=xlValues)
    End With

    Might work.

    --
    Regards,
    Tom Ogilvy

    "John" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Can anyone help please, I have a time line created with the code below
    > (where d3=0), so the time increments by 30 minutes and is displayed on the
    > worksheet formted as time
    >
    > e.g.
    >
    > 0:30
    > 1:00
    > 1:30
    > 2:00 etc etc
    >
    > objExcel.Cells(4, 4).Formula = "=$D3+time(0,30,0)"
    >
    > With objExcel
    > Set objRange1 = .Cells(4, 4)
    > Set objRange2 = .Range(.Cells(4, 4), .Cells(LastRow, 4))
    > End With
    >
    > objRange1.AutoFill objRange2
    >
    > then I retrieve start and end times from a database, I want to search the
    > sheet for the times, but because there is a mismatch between string and

    time
    > i do not get any results with c and d both being set to nothing, how to i
    > resolve this to get a match ?? x would equal "09:30" for example
    >
    >
    > x = Trim(rs.Fields("Start Time"))
    > y = Trim(rs.Fields("End Time"))
    >
    > With Worksheets(2).Range("d1:d52")
    > Set c = .Find(x, LookIn:=xlValues)
    > Set d = .Find(y, LookIn:=xlValues)
    > End With
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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