#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Adding Time


Is there a command - or easy way to add minutes and seconds (rather
than converting everything to seconds etc.) ?

Thanks - Kirk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Adding Time

Answering my own question!
Did no one esle know, or was it so obvious as to be a silly
question ? :)

Anyway this seems to work, but there maybe some glitch
not envisaged. Any comments, criticisms welcome!

--

Function AddTimes(ByVal t1, t2)
'Adds MINS and SECS
' format "02:50" , "03 45", "4:33" etc

Dim t1s, t2s, tt
t1s = Split(t1, " ")
If UBound(t1s) < 1 Then t1s = Split(t1, ":")
t2s = Split(t2, " ")
If UBound(t2s) < 1 Then t2s = Split(t2, ":")
tt = TimeSerial(0, t1s(0), t1s(1)) + TimeSerial(0, t2s(0), t2s(1))

If Val(Format(tt, "hh")) = 0 Then
AddTimes = Format(tt, "nn:ss")
Else
AddTimes = Format(tt, "hh:nn:ss")
End If
End Function
--


I wanted it to handle various Minutes and Seconds formats and
it doesn't check for bad input as there shouldn't be any !

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
Adding time Liz Excel Worksheet Functions 2 October 6th 08 03:15 PM
Adding time AM/PM JoeyZaZa Excel Discussion (Misc queries) 2 June 20th 06 01:47 AM
Adding Time suicidal jackie Excel Worksheet Functions 1 April 11th 06 05:18 PM
Time log adding time from separate sheets teastman New Users to Excel 1 December 31st 05 04:14 PM
Adding time to date-time formatted cell tawtrey(remove this )@pacificfoods.com Excel Discussion (Misc queries) 4 August 12th 05 10:53 PM


All times are GMT +1. The time now is 11:42 PM.

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

About Us

"It's about Microsoft Excel"