Thread: Format Time
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Format Time

If you are doing that as a worksheet function then you can't change any
attributes with function, just return a result.

If you want negative time, use the 1904 date system
(ToolsOptionsCalculation).

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"JustMe" wrote in message
. ..
Could someone please tell me why I cannot format SumAll as [h]:mm? It

gives
an answer of :03, when it should be 1618.20.

I'd also like to know how to format as Text "-[h]:mm" because I have some
other calculations that will result in a negative number of hours/minutes.

Thank you!

Function SumAll(rng As Range)
Dim cell As Range
SumAll = 0

For Each cell In rng
SumAll = SumAll + cell.Value
Next cell
SumAll = Format(SumAll / 86400, "[h]:mm") 'convert seconds to
hours/minutes
End Function