View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Convert Time to Text

"If" wrote:
Is it possible to convert a time to text
Example : 12:20:00 --- 12 h 20 (texte format)
I know the procedure =TEXT ...
Is there something but in vba?


The VBA Format function is similar to the Excel TEXT function. For example:

Const d As Double = #12:20:00 PM#
MsgBox Format(d, "h \h m")

If 12:20:00 is in A1 (formatted any way you wish), you could also do:

=TEXT(A1, "h \h m")

And you can do:

=A1

with the Custom format "h \h m" without quotes.