Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Alphanumeric custom formats

does anyone know how to create a custom format in Excel 2007 that will all
you to enter this: 123456B789 and it automatically changes it to
12-3456-B-789

The letter can change so the mask should be able to accomodate that. I
found one that will work if the letter is always the same - but it won't work
if it's anything other than a B.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 320
Default Alphanumeric custom formats

There is no mask-edit in Excel for text -- your best bet would be to enter
the value elsewhere and reference that cell in a formula, like:
=LEFT(Z2,2)&"-"&MID(Z2,3,4)&"-"&MID(Z2,7,1)&"-"&RIGHT(Z2,3)

"May47" wrote in message
...
does anyone know how to create a custom format in Excel 2007 that will all
you to enter this: 123456B789 and it automatically changes it to
12-3456-B-789

The letter can change so the mask should be able to accomodate that. I
found one that will work if the letter is always the same - but it won't
work
if it's anything other than a B.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,240
Default Alphanumeric custom formats

May47 wrote:
does anyone know how to create a custom format in Excel 2007 that will all
you to enter this: 123456B789 and it automatically changes it to
12-3456-B-789

The letter can change so the mask should be able to accomodate that. I
found one that will work if the letter is always the same - but it won't work
if it's anything other than a B.



Excel allows custom *number* formats. What you are entering is text. I believe
this would require some programming.
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Alphanumeric custom formats

Not a Custom format but how about event code that formats when you enter the
data?

Same as Bob's helper cell formula except in place.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 Then
On Error GoTo endit
Application.EnableEvents = False
If Len(Target) = 10 Then
Target.Value = Left(Target, 2) & "-" _
& Mid(Target, 3, 4) & "-" _
& Mid(Target, 7, 1) & "-" _
& Right(Target, 3)
End If
endit:
Application.EnableEvents = True
End If
End Sub

Right-click on the sheet tab and "View Code". Copy/paste into that module.
Edit to suit then Alt + q to return to the Excel window.


Gord Dibben MS Excel MVP

On Fri, 20 Feb 2009 11:33:02 -0800, May47
wrote:

does anyone know how to create a custom format in Excel 2007 that will all
you to enter this: 123456B789 and it automatically changes it to
12-3456-B-789

The letter can change so the mask should be able to accomodate that. I
found one that will work if the letter is always the same - but it won't work
if it's anything other than a B.


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
Custom Formats Karen Excel Discussion (Misc queries) 1 June 27th 08 10:21 AM
Custom Alphanumeric Format tkeith Excel Discussion (Misc queries) 1 July 29th 06 01:20 AM
Custom Formats centerNegative Excel Discussion (Misc queries) 3 October 7th 05 05:01 PM
Custom Formats becky Excel Discussion (Misc queries) 6 December 24th 04 01:24 AM
Custom Formats Stan Altshuller Excel Worksheet Functions 1 December 13th 04 09:47 PM


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

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"