Results 1 to 5 of 5

Cell Value Shows Time But Value returns as Decimal

Threaded View

  1. #1
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Cell Value Shows Time But Value returns as Decimal

    Good Morning,

    I have a issue in some logic I was hoping someone can point me in the right direction.

    My Script pulls a start time and a end time via a min and max formula I then subtract these times to get working hours. I format the cell as "hh:mm:ss"
    The cell value shows the time in "hh:mm:ss"

    However the logic I'm using below looks at this cells time to determine how many hours they worked. in the example attached the person only worked 00:00:42 seconds so that is well under the 04:00:00 time yet the script walks right past this line.

    So I placed a msgbox in the script to see what the value being returned was and it's a decimal.

    Now How can I get the script to react to the time and not the decimal?

    Range("B6").FormulaR1C1 = "=min(R[16]C[8]:R" & lrow & "C[8])"
    Range("B7").FormulaR1C1 = "=max(R[15]C[8]:R" & lrow & "C[8])"
    Range("B8").FormulaR1C1 = "=R[-1]C-R[-2]C"
     
    Range("B8").NumberFormat = "hh:mm:ss"
     
    'NEED TO ADJUST BREAK TIMES
     
    Msgbox Range("b8").Value 'REMOVE THIS
     
    'If Range("B8").Value < ".166666666666667" Then
     
    If Range("B8").Value <= "04:00:00" Then
        Range("A9").Value = "00:15:00"
    ElseIf Range("B8").Value >= "04:00:00" And Range("B8").Value <= "08:00:00" Then
        Range("A9").Value = "00:45:00"
    ElseIf Range("B8").Value > "08:00:00" And Range("B8").Value <= "12:00:00" Then
        Range("A9").Value = "01:00:00"
    ElseIf Range("B8").Value > "12:00:00" Then
        Range("A9").Value = "01:15:00"
    End If
    Attached Files Attached Files
    Last edited by realniceguy5000; 06-14-2011 at 09:08 AM.
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

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