ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro to change time format.... (https://www.excelbanter.com/excel-worksheet-functions/172065-macro-change-time-format.html)

neilcarden

Macro to change time format....
 
1 Attachment(s)
Hi, please see attached....

I need a macro to put the times into 'hh:mm' format. At the minute some are 'h:mm' and they are all in text format.

Is there a way to run a macro on the times to change all to 'hh:mm'?

Thanks
Neil

Bernie Deitrick

Macro to change time format....
 
Neil,

Select all the cells that need to be changed and run the macro below.

HTH,
Bernie
MS Excel MVP

Sub ChangeTimeStringsToTimes()
Dim myC As Range
For Each myC In Selection
myC.Value = TimeValue(myC.Value)
myC.NumberFormat = "hh:mm"
Next myC
End Sub


"neilcarden" wrote in message
...

Hi, please see attached....

I need a macro to put the times into 'hh:mm' format. At the minute some
are 'h:mm' and they are all in text format.

Is there a way to run a macro on the times to change all to 'hh:mm'?

Thanks
Neil


+-------------------------------------------------------------------+
|Filename: Whereabouts2.zip |
|Download: http://www.excelbanter.com/attachment.php?attachmentid=104|
+-------------------------------------------------------------------+



--
neilcarden





All times are GMT +1. The time now is 05:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com