Macro to change time format....

  • Thread starter Thread starter neilcarden
  • Start date Start date
N

neilcarden

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|
+-------------------------------------------------------------------+
 
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
 
Back
Top