LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Macro / function text time to 24hr excel time passed midnight fortotaling hr's

I am working on rosters
And because the rosters finish past midnight
I need to be able to let excel know this

To be able to calculate the times into total hours
Times entered into excel have to go in as 24hr clock but for
Excel to recognize times that are after midnight they are entered as
I.e. 24:00, 25:00, 26:00 to represent 12:00(midnight), 1:00am 2:00am
As on a 36hr clock,
These times are repozented as:-

412a are normal am
412p are afternoon PM
412x are after midnight Pm

When entered as 24hr clock cells are formatted to change to am/pm

So the problem is to change text time to Excel time over 24hr with a
macro and Function
The the Function that I am using with the macro, does not recognize
more than 24hr’s

Times to change text time to excel time
Time formats as below

Change 412a into Excel time 4:12
412p into Excel time 16:12
412x into Excel time 28:12

How can I ajust the function to achive this with the 'X'

+ Hrs = CInt(Hrs) + 24
does not work

The macro and function I am using is below
------------------------------------------------------------------
Function GetValue(s As String) As String

Dim Hrs As String

Dim Mins As String

If s < "" Then

Do Until Len(s) = 5

s = "0" + s

Loop

Hrs = Left(s, 2)

Mins = Right(s, 3)

Mins = Left(Mins, 2)

If UCase(Right(s, 1)) = "A" Then

ElseIf UCase(Right(s, 1)) = "P" Then

If Hrs < "12" Then

Hrs = CInt(Hrs) + 12

End If

End If

s = Hrs & ":" & Mins

End If

GetValue = s

End Function
--------------------------------
Thanks for any help on this
Russell
 
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
Formating 24hr Clock, but not as time!! SpencerMC Excel Discussion (Misc queries) 13 May 10th 08 01:42 AM
Time after midnight Steved Excel Worksheet Functions 2 May 30th 07 08:10 PM
time around midnight Mai-Britt Excel Worksheet Functions 2 May 9th 07 01:05 PM
Do not convert 24hr time in Excel to Portugese postal code Art Welch Excel Discussion (Misc queries) 0 August 28th 06 05:10 PM
subtraction off time after midnight Steved Excel Worksheet Functions 2 May 24th 06 01:46 AM


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