Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Jay
 
Posts: n/a
Default 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   Report Post  
Fredrik Wahlgren
 
Posts: n/a
Default


"Jay" wrote in message
...
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



  #3   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Thu, 7 Apr 2005 13:33:07 -0700, Jay 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
  #4   Report Post  
Jay
 
Posts: n/a
Default

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" wrote in message
...
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   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Fri, 8 Apr 2005 03:03:05 -0700, Jay 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   Report Post  
Jay
 
Posts: n/a
Default

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 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   Report Post  
Fredrik Wahlgren
 
Posts: n/a
Default


"Jay" wrote in message
...
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   Report Post  
Fredrik Wahlgren
 
Posts: n/a
Default


"Jay" wrote in message
...
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





Attached Files
File Type: zip SumTime.zip (7.6 KB, 154 views)
  #9   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Fri, 8 Apr 2005 03:57:04 -0700, Jay 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 09:53 PM
Function or Code Allan Excel Worksheet Functions 2 March 16th 05 07:55 PM
UDF and Calculation tree Ken Wright Links and Linking in Excel 1 February 6th 05 05:58 PM
Trim function doesn't clean out ASCII Code 160 (Space) Ronald Dodge Excel Worksheet Functions 6 January 27th 05 04:48 AM
How to resize a comment box, by embedding code into a function? JJ Excel Worksheet Functions 13 November 16th 04 09:44 PM


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"