+ Reply to Thread
Results 1 to 3 of 3

Trying to determine start and end cell numbers

  1. #1
    Registered User
    Join Date
    09-20-2007
    Posts
    7

    Trying to determine start and end cell numbers

    Hi

    I have two columns of numbers as shown. In cells B1 to B10, there are numbers representing hours, minutes, seconds and milliseconds.

    A B
    1 00:00:01.640
    2 00:00:03.718
    3 00:00:05.796
    4 00:00:07.875
    5 00:00:09.953
    6 00:00:12.031
    7 00:00:14.109
    8 00:00:16.140
    9 00:00:18.156
    10 00:00:20.234

    I have a userform where I want to input a start_time (say 00:00:05) and end time (say 00:00:16) and I need to search the 10 numbers to find the subset start and end cell. In other words, I want to be able to see that the cells I am interested in are from B3 to B8.

    I have created a for loop which looks at each B cell and compares with a starttime as shown, however, I cannot seem to get the datatyes right for this to work. The datatype of the values in the B cells is 'number'. I have tried making the starttime datatime integer, number and even string and getting nowhere.

    For looper = 1 To 10
    If Range("B" & looper).Value < starttime Then
    count = count + 1
    End If
    Next looper

    Can anyone point me in the right direction?

    Martin

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Trying to determine start and end cell numbers

    You should format starttime as Double.

    Also set the value of starttime to be consistent with the actual values in column B:

    0.000018981481481
    0.000043032407407
    0.000067083333333
    0.000091145833333
    0.000115196759259
    0.000139247685185
    0.000163298611111
    0.000186805555556
    0.000210138888889
    0.000234189814815

    set starttime to:
    0.000057870370370
    Last edited by Jakobshavn; 03-07-2013 at 12:47 PM.
    Gary's Student

  3. #3
    Registered User
    Join Date
    09-20-2007
    Posts
    7

    Re: Trying to determine start and end cell numbers

    Hi Jakobshavn

    Thanks for your help. I ended up doing it another way to get it to work.

    Cheers

    Martin

+ 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