+ Reply to Thread
Results 1 to 6 of 6

Time query to find number of times in a certain range

  1. #1
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Time query to find number of times in a certain range

    Hello all,

    So I am trying to devise a code that will allow a user to input a range of times via dialog box. Then with this range (a startTime and endTime), the VBA code will search the worksheet and count the number of trips that take place in that time interval. I can't figure out a way to convert the user entry into a h:mm AM/PM format but I feel like I am on the right track.

    If anyone could take a look at my attached code/file and steer me in the right direction, that would be awesome! I would also be happy to clarify anything I left out, thank you.

    -Chad

    Please Login or Register  to view this content.
    timequery.xlsm

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Time query to find number of times in a certain range

    Please Login or Register  to view this content.
    fromTime is not defined as a cell or range. You need to format it a cell or range first before you test it with if.

  3. #3
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Time query to find number of times in a certain range

    Please Login or Register  to view this content.
    This code works for one column of times, however when I enter a range of times outside the specified row, count1 always returns "0" trips. How can I have it search multiple columns of time?

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Time query to find number of times in a certain range

    May be this line if worktotalDXdept1 is a named range

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Time query to find number of times in a certain range

    The number of items in it's column will always vary, so I'm not sure that would work out the way I'm hoping. I am trying to define fromTime and toTime as a range, but since these variables refer to the string of text from the userform's text box, I'm kind of confused how that would work. I feel like I'm so close to getting this thing right. Am I headed in the right direction? Still getting an error (Expected: Expression) with this:

    Please Login or Register  to view this content.
    Thank you for your help so far, AB33. Please let me know if you need any additional info. Please refer to this updated file: Book4.xlsm
    Last edited by aloha31; 08-13-2013 at 04:44 PM.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Time query to find number of times in a certain range

    Sorry!
    I can not test it, but you need to remove the hashes from these lines
    Please Login or Register  to view this content.
    You may putin dates in hashes but not any other.

+ 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] find number of times a letter or a number appears in a column
    By dcoates in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-17-2012, 02:47 PM
  2. Query around time formats and addition of times with large numbers
    By Grimace in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-05-2010, 04:10 AM
  3. Replies: 6
    Last Post: 03-02-2010, 04:15 PM
  4. Replies: 1
    Last Post: 04-08-2009, 05:24 AM
  5. Time (clock) times a number= very high number?
    By saadeet in forum Excel General
    Replies: 2
    Last Post: 04-02-2009, 11:24 AM

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