Number formatting will only work on numbers.
You can either use another cell with a formula in it:
=left(a1,2)&"-"&mid(a2,3,3)&"-"&mid(a2,6,2)
Or you could have an event macro...
If you want to try, right click on the worksheet tab that should have this
behavior. Select view code and paste this into the codewindow:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
'one cell at a time
If .Cells.Count > 1 Then Exit Sub
'only column A
If Intersect(Me.Range("A:A"), .Cells) Is Nothing Then Exit Sub
'gotta be 7 characters
If Len(.Value) <> 7 Then Exit Sub
On Error GoTo ErrHandler:
Application.EnableEvents = False
.Value = Left(.Value, 2) & "-" _
& Mid(.Value, 3, 3) & "-" & Mid(.Value, 6, 2)
End With
ErrHandler:
Application.EnableEvents = True
End Sub
I check for entries in column A. Change that to the range you want to use.
You can read more about events at:
Chip Pearson's site:
http://www.cpearson.com/excel/events.htm
David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm
If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm