PC Review


Reply
Thread Tools Rate Thread

Convert Time to Text

 
 
If
Guest
Posts: n/a
 
      15th Jul 2011

Hello,

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?

Thanks for your help.

Yves


 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      15th Jul 2011
> 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?


You can use the Format function in VBA...

YourTimeValue = #12:20:00#
MsgBox Format(YourTimeValue, "h \h mm")

Rick Rothstein (MVP - Excel)

 
Reply With Quote
 
joeu2004
Guest
Posts: n/a
 
      15th Jul 2011
"If" <(E-Mail Removed)> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I convert time as text 'mm:ss to time value in Excel Sholto Microsoft Excel Misc 5 1st Apr 2009 05:40 AM
convert time to text =?Utf-8?B?Y2hlY2tR?= Microsoft Excel Misc 9 11th May 2007 08:31 PM
Convert Text Time to Excel Time william.mcseveney@ntlworld.com Microsoft Excel Misc 5 29th Jan 2007 04:43 PM
convert time imported as text to time format for calculations =?Utf-8?B?YmF0ZmlzaA==?= Microsoft Excel Worksheet Functions 3 27th Oct 2005 11:24 PM
Convert text to time value Andy Microsoft Excel Misc 4 19th Nov 2004 06:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:20 AM.