Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default arithmetic on minutes and seconds without leading zero

I have a track and field worksheet and want to do arithmetic on sprint times
expressed as mm:ss or mm:ss.0. I can get it to work if I enter the times as
0:mm:ss, but entering the leading zero is tedious. Is it possible to enter
the times as mm:ss without the leading zero and get it to work as desired?

Best,
Christopher


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default arithmetic on minutes and seconds without leading zero

Hi,

Here is one possibility: Suppose the range where you will be entering the
times is A1:A10, and instead of entering 1:02 for 1 minute and 2 seconds,
enter 1.2

The code below will convert this to 0:01:02. It will not handle times
greater than 0:59:59 you will need to revise it if that is the case.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim center As Integer
Dim isect As Range
Set isect = Application.Intersect(Target, Range("A1:A10"))
If Not isect Is Nothing Then
On Error GoTo ErrorHandler
center = WorksheetFunction.Find(".", Target)
Application.EnableEvents = False
Target = "0:" & Left(Target, center - 1) & ":" & Mid(Target, center
+ 1, 10)
End If
ErrorHandler:
Application.EnableEvents = True
End Sub


--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Christopher Glaeser" wrote:

I have a track and field worksheet and want to do arithmetic on sprint times
expressed as mm:ss or mm:ss.0. I can get it to work if I enter the times as
0:mm:ss, but entering the leading zero is tedious. Is it possible to enter
the times as mm:ss without the leading zero and get it to work as desired?

Best,
Christopher



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
How do I change a minutes and seconds as a 2400 time to seconds? NickBrown419 Excel Worksheet Functions 1 August 10th 08 09:12 PM
Formula to Change Hours:Minutes:Seconds to Seconds only Cheri Excel Discussion (Misc queries) 4 August 30th 06 12:44 AM
custom number- minutes:seconds.hundredths how to hide a leading z pretzel Excel Discussion (Misc queries) 2 October 4th 05 02:50 PM
Convert "Time Interval" in "hours : minutes : seconds" to seconds Ianukotnorth New Users to Excel 7 May 8th 05 08:11 PM
Convert seconds to minutes and seconds in excel anonymous Excel Worksheet Functions 3 December 25th 04 08:38 PM


All times are GMT +1. The time now is 10:25 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"