PC Review


Reply
Thread Tools Rate Thread

Alphanumeric custom formats

 
 
May47
Guest
Posts: n/a
 
      20th Feb 2009
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 With Quote
 
 
 
 
Bob Umlas
Guest
Posts: n/a
 
      20th Feb 2009
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" <(E-Mail Removed)> wrote in message
news:3CE0EC1F-5046-4759-875D-(E-Mail Removed)...
> 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 With Quote
 
Glenn
Guest
Posts: n/a
 
      20th Feb 2009
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.
 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      20th Feb 2009
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 <(E-Mail Removed)>
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Alphanumeric Format =?Utf-8?B?dGtlaXRo?= Microsoft Excel Misc 1 29th Jul 2006 01:20 AM
AUTONUMBER- but with a custom alphanumeric =?Utf-8?B?TW9ybmluZ1N0YXJGYW4=?= Microsoft Access Database Table Design 4 9th Dec 2005 05:18 PM
Custom Formats centerNegative Microsoft Excel Misc 3 7th Oct 2005 05:01 PM
Re: Custom Formats John Vinson Microsoft Access Database Table Design 0 28th May 2005 02:49 AM
Re: Custom Formats Rick Brandt Microsoft Access Database Table Design 0 27th May 2005 10:54 PM


Features
 

Advertising
 

Newsgroups
 


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