Macro to change time format....

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|
+-------------------------------------------------------------------+
 
B

Bernie Deitrick

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top