Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How to format cells so they display A01-222-333-7777 or D01-222-3

I want to format a range of cells so that they display A01-222-333-7777 or
any other first letter in the string e.g. H02-111-444-8888 or
Z11-555-666-9999. I want to be able to just type the data and have Excel put
in the "-" between the entries, e.g. A012223337777 (Keyboard entry).

Text letter first, followed by a string of numbers that will be used as a
text only display with hypens between them. There will always be two numbers
following the the first letter, followed by three numbers with a dash and
three numbers with a dash ending with four numbers seperated with a dash.The
range will not be used in any calculations. Similar to a SSN but with a
letter designation first.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to format cells so they display A01-222-333-7777 or D01-222-3

You can't use format|cells|Numberformat--that only works with numbers.

But you could use a worksheet event.

If you want to try...

rightclick on the worksheet tab that should have this behavior. Select view
code and paste this in:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

With Target
If .Cells.Count 1 Then Exit Sub 'one cell at a time!
If Intersect(.Cells, Me.Range("a:a")) Is Nothing Then Exit Sub

If Len(.Text) < 13 Then
'do nothing
Else
Application.EnableEvents = False
.Value = Left(.Value, 3) & "-" _
& Mid(.Value, 4, 3) & "-" _
& Mid(.Value, 7, 3) & "-" _
& Right(.Value, 4)
Application.EnableEvents = True
End If
End With

End Sub

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


lmffblh wrote:

I want to format a range of cells so that they display A01-222-333-7777 or
any other first letter in the string e.g. H02-111-444-8888 or
Z11-555-666-9999. I want to be able to just type the data and have Excel put
in the "-" between the entries, e.g. A012223337777 (Keyboard entry).

Text letter first, followed by a string of numbers that will be used as a
text only display with hypens between them. There will always be two numbers
following the the first letter, followed by three numbers with a dash and
three numbers with a dash ending with four numbers seperated with a dash.The
range will not be used in any calculations. Similar to a SSN but with a
letter designation first.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,572
Default How to format cells so they display A01-222-333-7777 or D01-222-3

If you have the room on your sheet, you could designate a column strictly
for data input, and then use text formulas to display your data where and
how you wish.

Say you use Column T for your data input.

Enter this wherever you wish to display your data:

=LEFT(T1,3)&"-"&MID(T1,4,3)&"-"&MID(T1,7,3)&"-"&RIGHT(T1,4)

You can copy this down as needed to display the other contents of Column T.
--
HTH,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------

"lmffblh" wrote in message
...
I want to format a range of cells so that they display A01-222-333-7777 or
any other first letter in the string e.g. H02-111-444-8888 or
Z11-555-666-9999. I want to be able to just type the data and have Excel
put
in the "-" between the entries, e.g. A012223337777 (Keyboard entry).

Text letter first, followed by a string of numbers that will be used as a
text only display with hypens between them. There will always be two
numbers
following the the first letter, followed by three numbers with a dash and
three numbers with a dash ending with four numbers seperated with a
dash.The
range will not be used in any calculations. Similar to a SSN but with a
letter designation first.


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
Format Excel cells Steven Y Excel Discussion (Misc queries) 0 November 5th 05 02:00 AM
Display empty cells botany_girl Excel Discussion (Misc queries) 7 July 19th 05 06:40 PM
Display empty cells botany_girl Excel Discussion (Misc queries) 1 July 19th 05 05:51 PM
How to link cells and keep number format altogether Yi Excel Discussion (Misc queries) 0 May 6th 05 02:12 PM
When I select "format cells", the format dialog box does not disp. Andy S. Excel Worksheet Functions 2 November 23rd 04 03:49 AM


All times are GMT +1. The time now is 03:08 PM.

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

About Us

"It's about Microsoft Excel"