+ Reply to Thread
Results 1 to 2 of 2

Using VBA to determine a timespan

  1. #1
    Registered User
    Join Date
    06-19-2015
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    30

    Using VBA to determine a timespan

    Hello,

    I am trying to work out a bit of code that looks at a cell (formatted as time, preferably "h:mm:ss;@") and will then output a number in another cell if that time is within a timespan.

    This is what I want to happen:
    Time Charge
    0:15:00 1
    0:46:00 2
    1:15:01 3

    The time is already determined with a formula (=E4-C4)

    The timespans are: between 0:00:00 and 0:30:00, between 0:30:01 and 1:00:00, between 1:00:01 and 1:30:00, and so on by half-hour increments until it reaches 2:30:00.

    What I have currently is this:
    Please Login or Register  to view this content.
    This is not working at all and I do not know what I'm doing wrong. I know I could have this as a formula within the cell but I would like to avoid that if at all possible.

  2. #2
    Registered User
    Join Date
    06-19-2015
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    30

    Re: Using VBA to determine a timespan

    I figured it out! There is a function called TIMEVALUE which did exactly what I needed. Here is the updated code:

    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] Formula to calculate: # of hours in a timespan that fall between Midnight and 6AM
    By Deicidium in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 07-23-2015, 05:05 PM
  2. [SOLVED] Determine if last row is odd or even
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-31-2014, 02:36 PM
  3. Replies: 6
    Last Post: 10-01-2012, 10:52 AM
  4. Timespan formatting
    By eldidd in forum Excel General
    Replies: 5
    Last Post: 10-08-2008, 05:33 AM
  5. [SOLVED] How to Determine 1st, 2nd & 3rd for a PWD
    By Pete n PWD Land in forum Excel General
    Replies: 3
    Last Post: 02-18-2005, 10:06 AM
  6. Determine 1st 2nd 3rd in PWD
    By Pete n PWD Land in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2005, 04:52 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