+ Reply to Thread
Results 1 to 9 of 9

HELP with function, possibly code!

  1. #1
    Jay
    Guest

    HELP with function, possibly code!

    I have this column AU5 through AU35 which contain time values. What I'd like
    to do is add these values together. Is this possible? I also need to acount
    for cells which may or may not contain any value at all. Is this possible?
    ALL THE RESULTING VALUES I'VE GOTTEN THUS FAR ARE THE WRONG ONES! 00:00 is
    really 12 mid-night, I'm not sure if we take those as 12 mid-night or just a
    value. Anyway, can anyone out there assist? Thanks,

    02:00
    00:20
    02:05
    00:20
    00:25
    00:00
    00:30
    01:38

    01:57
    01:45
    00:20

    00:40
    00:20
    01:05
    03:00
    00:05
    00:00
    00:00
    01:00
    00:45



  2. #2
    Ron Rosenfeld
    Guest

    Re: HELP with function, possibly code!

    On Thu, 7 Apr 2005 13:33:07 -0700, Jay <[email protected]> wrote:

    >I have this column AU5 through AU35 which contain time values. What I'd like
    >to do is add these values together. Is this possible? I also need to acount
    >for cells which may or may not contain any value at all. Is this possible?
    >ALL THE RESULTING VALUES I'VE GOTTEN THUS FAR ARE THE WRONG ONES! 00:00 is
    >really 12 mid-night, I'm not sure if we take those as 12 mid-night or just a
    >value. Anyway, can anyone out there assist? Thanks,
    >
    >02:00
    >00:20
    >02:05
    >00:20
    >00:25
    >00:00
    >00:30
    >01:38
    >
    >01:57
    >01:45
    >00:20
    >
    >00:40
    >00:20
    >01:05
    >03:00
    >00:05
    >00:00
    >00:00
    >01:00
    >00:45
    >


    =SUM(AU5:AU35)

    Format the result as

    Format/Cells/Number/Custom Type: [h]:mm

    I get 18:15 for your values above.
    --ron

  3. #3
    Fredrik Wahlgren
    Guest

    Re: HELP with function, possibly code!


    "Jay" <[email protected]> wrote in message
    news:[email protected]...
    > I have this column AU5 through AU35 which contain time values. What I'd

    like
    > to do is add these values together. Is this possible? I also need to

    acount
    > for cells which may or may not contain any value at all. Is this possible?
    > ALL THE RESULTING VALUES I'VE GOTTEN THUS FAR ARE THE WRONG ONES! 00:00 is
    > really 12 mid-night, I'm not sure if we take those as 12 mid-night or just

    a
    > value. Anyway, can anyone out there assist? Thanks,
    >
    > 02:00
    > 00:20
    > 02:05
    > 00:20
    > 00:25
    > 00:00
    > 00:30
    > 01:38
    >
    > 01:57
    > 01:45
    > 00:20
    >
    > 00:40
    > 00:20
    > 01:05
    > 03:00
    > 00:05
    > 00:00
    > 00:00
    > 01:00
    > 00:45
    >
    >


    Can you explain the rules you want to use. You mst tell what you expect and
    how you came up with this value.If the list consisted of a single value like
    00:00, would you expect the sum to be 12? What about the sum of 00:00 and
    00:00 or 00:00 and 00:20 ?

    /Fredrik




  4. #4
    Jay
    Guest

    Re: HELP with function, possibly code!

    Fredrik:

    Yes, the 00:00 would be 12 and the 00:20 would be 12:20 (12 hrs and 20
    mmins). Hope this helps. Looking forward to your solution.

    Thanks,


    "Fredrik Wahlgren" wrote:

    >
    > "Jay" <[email protected]> wrote in message
    > news:[email protected]...
    > > I have this column AU5 through AU35 which contain time values. What I'd

    > like
    > > to do is add these values together. Is this possible? I also need to

    > acount
    > > for cells which may or may not contain any value at all. Is this possible?
    > > ALL THE RESULTING VALUES I'VE GOTTEN THUS FAR ARE THE WRONG ONES! 00:00 is
    > > really 12 mid-night, I'm not sure if we take those as 12 mid-night or just

    > a
    > > value. Anyway, can anyone out there assist? Thanks,
    > >
    > > 02:00
    > > 00:20
    > > 02:05
    > > 00:20
    > > 00:25
    > > 00:00
    > > 00:30
    > > 01:38
    > >
    > > 01:57
    > > 01:45
    > > 00:20
    > >
    > > 00:40
    > > 00:20
    > > 01:05
    > > 03:00
    > > 00:05
    > > 00:00
    > > 00:00
    > > 01:00
    > > 00:45
    > >
    > >

    >
    > Can you explain the rules you want to use. You mst tell what you expect and
    > how you came up with this value.If the list consisted of a single value like
    > 00:00, would you expect the sum to be 12? What about the sum of 00:00 and
    > 00:00 or 00:00 and 00:20 ?
    >
    > /Fredrik
    >
    >
    >
    >


  5. #5
    Ron Rosenfeld
    Guest

    Re: HELP with function, possibly code!

    On Fri, 8 Apr 2005 03:03:05 -0700, Jay <[email protected]> wrote:

    >Yes, the 00:00 would be 12 and the 00:20 would be 12:20 (12 hrs and 20
    >mmins). Hope this helps. Looking forward to your solution.
    >
    >Thanks,


    If 00:00 = 12; what does 12:00 equal?


    --ron

  6. #6
    Jay
    Guest

    Re: HELP with function, possibly code!

    It also equals 12. These are periods of time (durations from one to another,
    Beginning to End) for a production process. They folks I work for decided to
    use Excel and Excel does not seem to like these time values much. HELP!

    Thanks again.



    "Ron Rosenfeld" wrote:

    > On Fri, 8 Apr 2005 03:03:05 -0700, Jay <[email protected]> wrote:
    >
    > >Yes, the 00:00 would be 12 and the 00:20 would be 12:20 (12 hrs and 20
    > >mmins). Hope this helps. Looking forward to your solution.
    > >
    > >Thanks,

    >
    > If 00:00 = 12; what does 12:00 equal?
    >
    >
    > --ron
    >


  7. #7
    Fredrik Wahlgren
    Guest

    Re: HELP with function, possibly code!


    "Jay" <[email protected]> wrote in message
    news:[email protected]...
    > Fredrik:
    >
    > Yes, the 00:00 would be 12 and the 00:20 would be 12:20 (12 hrs and 20
    > mmins). Hope this helps. Looking forward to your solution.
    >
    > Thanks,
    >


    What is the total for the time values that you have provided? I can make a
    UDF but I want something to compare with.
    /Fredrik



  8. #8
    Fredrik Wahlgren
    Guest

    Re: HELP with function, possibly code!


    "Jay" <[email protected]> wrote in message
    news:[email protected]...
    > I have this column AU5 through AU35 which contain time values. What I'd

    like
    > to do is add these values together. Is this possible? I also need to

    acount
    > for cells which may or may not contain any value at all. Is this possible?
    > ALL THE RESULTING VALUES I'VE GOTTEN THUS FAR ARE THE WRONG ONES! 00:00 is
    > really 12 mid-night, I'm not sure if we take those as 12 mid-night or just

    a
    > value. Anyway, can anyone out there assist? Thanks,
    >
    > 02:00
    > 00:20
    > 02:05
    > 00:20
    > 00:25
    > 00:00
    > 00:30
    > 01:38
    >
    > 01:57
    > 01:45
    > 00:20
    >
    > 00:40
    > 00:20
    > 01:05
    > 03:00
    > 00:05
    > 00:00
    > 00:00
    > 01:00
    > 00:45
    >
    >


    I have written a UDF which gives me a total of 162 hrs and 15 min. Right
    now, it doesn't account for empty cells but that's easy to fix, First, I
    want to know whether you think this is the right value. Select
    Tools|Macro|Visual Basic Editor.. and insert a new module. Then paste the
    code below. You can't have empty cells. I have attached the workbook. I use
    the Swedish version of Excel in case you wonder.

    /Fredrik

    Public Function SumTime(ByVal r As Range) As String
    Dim Items As Long
    Dim i As Long
    Dim pos As Long
    Dim strlen As Long
    Dim hours As Long
    Dim htemp As Long
    Dim mins As Long
    'It is assumed that each value in the range consists of two
    'numerical values separated by a : sign. The macro doesn't check
    'the validity which means that it will accept something like 123:76

    Items = r.Columns.Count * r.Rows.Count

    If 0 = Items Then
    SumTime = ""
    Exit Function
    End If

    'Just for clarity
    hours = 0
    mins = 0

    For i = 1 To Items
    strlen = Len(r(i))
    pos = InStr(1, r(i), ":", vbTextCompare)

    htemp = CLng(Left(r(i), strlen - pos))

    If 0 = htemp Then
    hours = hours + 12
    Else
    hours = hours + htemp
    End If

    mins = mins + CLng(Right(r(i), strlen - pos))

    If 60 <= mins Then
    hours = hours + 1
    mins = mins - 60
    End If
    Next i

    SumTime = CStr(hours) & ":" & CStr(mins)
    End Function






  9. #9
    Ron Rosenfeld
    Guest

    Re: HELP with function, possibly code!

    On Fri, 8 Apr 2005 03:57:04 -0700, Jay <[email protected]> wrote:

    >It also equals 12. These are periods of time (durations from one to another,
    >Beginning to End) for a production process. They folks I work for decided to
    >use Excel and Excel does not seem to like these time values much. HELP!
    >
    >Thanks again.
    >
    >
    >


    I think we need to know how these time periods are being entered and computed.

    What you want to do seems simple enough, but if 00:00 represents a period of
    time in Excel, it would ordinarily represent a multiple of 24 hours (including
    0). If, in your template, it is representative of only 12 hours, there is
    something going on that I don't understand.

    How do you represent a production process that lasts more than 12 hours?

    If you are entering start and stop times, or start and stop dates and times, to
    compute and sum up a set of time periods is simple. I suspect you are having a
    problem with either formatting, or with data entry.



    --ron

+ 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