LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Number formatting only works on numbers.

But you could use a little macro waiting for you to make a change to a cell.

If that sounds ok, right click on the worksheet tab that should have this
behavior and select view code. Paste this in:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

'XX:XXXX:XX
On Error GoTo ErrHandler:

With Target
If .NumberFormat = "@" Then
If Len(.Value) = 8 Then
'do it!
Application.EnableEvents = False
.Value = Left(.Value, 2) & ":" & Mid(.Value, 3, 4) _
& ":" & Right(.Value, 2)
End If
End If
End With

ErrHandler:
Application.EnableEvents = True

End Sub

The code looks to make sure that your cell is formatted as Text and that it's
exactly 8 characters long.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

mustard wrote:

I would like to have text custom formatted so that if a 8 character
words is typed, it is automatically broken up like this XX:XXXX:XX.
This works just fine with numbers with a ##\:####\:## custom format,
but it will not work for text. Any suggestions?

--
mustard
------------------------------------------------------------------------
mustard's Profile: http://www.excelforum.com/member.php...o&userid=20017
View this thread: http://www.excelforum.com/showthread...hreadid=346023


--

Dave Peterson
 
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
Custom format a text cell with square brackets: [ ] ? StargateFan Excel Discussion (Misc queries) 2 February 6th 05 03:35 PM
how to format numbers stored as text or vice versa to use vlookup teneagle Excel Worksheet Functions 1 February 3rd 05 10:41 PM
how to format excel format to text format with separator "|" in s. azlan New Users to Excel 1 January 31st 05 12:57 PM
How do i change numbers in text format to number format? Greg New Users to Excel 1 December 14th 04 05:22 PM
How to write a "Text" or date custom format FBB Excel Worksheet Functions 1 November 28th 04 01:10 AM


All times are GMT +1. The time now is 03:59 AM.

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"