Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro "Time formatting" help

I've got a column of "Time" information that doesn't have a colon separating
the hours from the minutes. I'm looking for a macro to:

move 2 places to the left
insert ":"

An example of the data are
0957
1412
1952

and I want
09:57
14:12
19:52

The data begin at B2.

Thanks,
Norm
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro "Time formatting" help

Sure you need a macro? You could try this formula:

=--TEXT(A1,"00\:00")

Or, with a macro:

Public Sub SelectionToTime()
Dim rCell As Range
For Each rCell In Selection.Cells
With rCell
If .Text Like "####" Then
.Value = TimeValue(Format(.Text, "00\:00"))
.NumberFormat = "[hh]:mm"
End If
End With
Next rCell
End Sub



In article ,
Norm Shea wrote:

I've got a column of "Time" information that doesn't have a colon separating
the hours from the minutes. I'm looking for a macro to:

move 2 places to the left
insert ":"

An example of the data are
0957
1412
1952

and I want
09:57
14:12
19:52

The data begin at B2.

Thanks,
Norm

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro "Time formatting" help

JE,

You are right, I don't need a macro. Worked wonderfully! Where are all
these formulas hidden?! I am always amazed (and appreciative) at how quickly
and effectively questions are responded to.

Thanks,
Norm


"JE McGimpsey" wrote:

Sure you need a macro? You could try this formula:

=--TEXT(A1,"00\:00")

Or, with a macro:

Public Sub SelectionToTime()
Dim rCell As Range
For Each rCell In Selection.Cells
With rCell
If .Text Like "####" Then
.Value = TimeValue(Format(.Text, "00\:00"))
.NumberFormat = "[hh]:mm"
End If
End With
Next rCell
End Sub



In article ,
Norm Shea wrote:

I've got a column of "Time" information that doesn't have a colon separating
the hours from the minutes. I'm looking for a macro to:

move 2 places to the left
insert ":"

An example of the data are
0957
1412
1952

and I want
09:57
14:12
19:52

The data begin at B2.

Thanks,
Norm


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Diff. change headline in "Formatting" or "Outlining" toolbar? Bernd Oninger Excel Discussion (Misc queries) 1 November 10th 08 11:02 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running [email protected] Excel Programming 5 May 16th 07 08:18 PM
macro for converting number stored as "text" (or preceeded with ') to "number" formatting markx Excel Programming 1 June 30th 06 12:14 PM
macro for converting number stored as "text" (or preceeded with ') to "number" formatting markx Excel Programming 1 June 23rd 06 03:15 PM


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

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

About Us

"It's about Microsoft Excel"