#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Format Text

I'm trying to format order numbers in excel and I want dashes to fill in
automatically. The problem is I have numbers and text for each order. For
example: SRT46510D1234 is what I want to type in, but I want it to appear as
SRT456-10-D-1234. Is there a way to make that happen?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Format Text

You can not have th eformat directly in the cell you are entering in. XL does
not have a facility for input masks or formats on text. You can output the
formatted text in a seperate cell with a formulas such as this

=LEFT(A1, 6) & "-" & MID(A1, 7, 2) & "-" & MID(A1, 9, 1) & "-" & MID(A1, 10,
256)
where your input was in cell A1
--
HTH...

Jim Thomlinson


"Hughes" wrote:

I'm trying to format order numbers in excel and I want dashes to fill in
automatically. The problem is I have numbers and text for each order. For
example: SRT46510D1234 is what I want to type in, but I want it to appear as
SRT456-10-D-1234. Is there a way to make that happen?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Format Text

You can either use a formula in another cell, or translate them in place
automatically with an Event Macro:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range, t As Range
Dim v As String, s As String
Set A = Range("A:A")
Set t = Target
s = "-"
If Intersect(t, A) Is Nothing Then Exit Sub
v = t.Value
v = Left(v, 6) & s & Mid(v, 7, 2) & s & Mid(v, 9, 1) & s & Right(v, 4)
Application.EnableEvents = False
t.Value = v
Application.EnableEvents = True
End Sub

This will auto-translate entries made in column A.

Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu201001


"Hughes" wrote:

I'm trying to format order numbers in excel and I want dashes to fill in
automatically. The problem is I have numbers and text for each order. For
example: SRT46510D1234 is what I want to type in, but I want it to appear as
SRT456-10-D-1234. Is there a way to make that happen?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,718
Default Format Text

=REPLACE(REPLACE(REPLACE(A1,7,,"-"),10,,"-"),12,,"-")


"Hughes" wrote:

I'm trying to format order numbers in excel and I want dashes to fill in
automatically. The problem is I have numbers and text for each order. For
example: SRT46510D1234 is what I want to type in, but I want it to appear as
SRT456-10-D-1234. Is there a way to make that happen?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Format Text

A variation of TM's suggestion:

=REPLACE(REPLACE(REPLACE(A1,10,,"-"),9,,"-"),7,,"-")

The numbers are in largest to smallest, and refer to the position in the
original string.

(It made the counting easier for me.)



Teethless mama wrote:

=REPLACE(REPLACE(REPLACE(A1,7,,"-"),10,,"-"),12,,"-")

"Hughes" wrote:

I'm trying to format order numbers in excel and I want dashes to fill in
automatically. The problem is I have numbers and text for each order. For
example: SRT46510D1234 is what I want to type in, but I want it to appear as
SRT456-10-D-1234. Is there a way to make that happen?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Format Text

But an input mask is something that you can use in Access, right? Is there a
way to format it in Access even if the numbers and letters don't always
appear in the same place?

"Jim Thomlinson" wrote:

You can not have th eformat directly in the cell you are entering in. XL does
not have a facility for input masks or formats on text. You can output the
formatted text in a seperate cell with a formulas such as this

=LEFT(A1, 6) & "-" & MID(A1, 7, 2) & "-" & MID(A1, 9, 1) & "-" & MID(A1, 10,
256)
where your input was in cell A1
--
HTH...

Jim Thomlinson


"Hughes" wrote:

I'm trying to format order numbers in excel and I want dashes to fill in
automatically. The problem is I have numbers and text for each order. For
example: SRT46510D1234 is what I want to type in, but I want it to appear as
SRT456-10-D-1234. Is there a way to make that happen?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Format Text

Yes you can set up an input mask in Access but they are static. Check on the
Access news group for all of the options in that part of the world...
--
HTH...

Jim Thomlinson


"Hughes" wrote:

But an input mask is something that you can use in Access, right? Is there a
way to format it in Access even if the numbers and letters don't always
appear in the same place?

"Jim Thomlinson" wrote:

You can not have th eformat directly in the cell you are entering in. XL does
not have a facility for input masks or formats on text. You can output the
formatted text in a seperate cell with a formulas such as this

=LEFT(A1, 6) & "-" & MID(A1, 7, 2) & "-" & MID(A1, 9, 1) & "-" & MID(A1, 10,
256)
where your input was in cell A1
--
HTH...

Jim Thomlinson


"Hughes" wrote:

I'm trying to format order numbers in excel and I want dashes to fill in
automatically. The problem is I have numbers and text for each order. For
example: SRT46510D1234 is what I want to type in, but I want it to appear as
SRT456-10-D-1234. Is there a way to make that happen?

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
Need help with converting CUSTOM format/TEXT format to DATE format Deo Cleto Excel Worksheet Functions 6 June 2nd 09 08:14 PM
Change Date Format to Specific Text Format When Copying [email protected] Excel Discussion (Misc queries) 4 December 23rd 08 03:43 PM
Convert numbers from text format to number format merlin68 Excel Discussion (Misc queries) 7 June 20th 07 07:03 PM
Change number (in text format) to numeric format Pam Excel Discussion (Misc queries) 5 October 24th 05 07:45 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


All times are GMT +1. The time now is 12:22 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"