A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Convert Time to Text



 
 
Thread Tools Display Modes
  #1  
Old July 15th 11, 12:17 AM posted to microsoft.public.excel.programming
If[_3_]
external usenet poster
 
Posts: 6
Default Convert Time to Text


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


Ads
  #2  
Old July 15th 11, 05:43 AM posted to microsoft.public.excel.programming
Rick Rothstein
external usenet poster
 
Posts: 5,934
Default Convert Time to Text

> 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)

  #3  
Old July 15th 11, 08:03 AM posted to microsoft.public.excel.programming
joeu2004[_2_]
external usenet poster
 
Posts: 648
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.

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert time to text Jacqueline Excel Worksheet Functions 5 August 4th 09 06:35 PM
How do I convert time as text 'mm:ss to time value in Excel Sholto Excel Discussion (Misc queries) 5 April 1st 09 05:40 AM
convert time to text checkQ Excel Discussion (Misc queries) 9 May 11th 07 08:31 PM
Convert Text Time to Excel Time [email protected] Excel Discussion (Misc queries) 5 January 29th 07 04:43 PM
convert time imported as text to time format for calculations batfish Excel Worksheet Functions 3 October 27th 05 11:24 PM


All times are GMT +1. The time now is 09:18 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2004-2013 ExcelBanter.
The comments are property of their posters.