View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
John C[_2_] John C[_2_] is offline
external usenet poster
 
Posts: 1,358
Default Custom number format for driver's license number

With some error checking:
=IF(B1="","",IF(AND(LEN(B1)=14,OR(AND(CODE(LEFT(B1 ,1))64,CODE(LEFT(B1,1))<91),AND(CODE(LEFT(B1,1)) 96,CODE(LEFT(B1,1))<123)),ISNUMBER(--RIGHT(B1,LEN(B1)-1))),UPPER(LEFT(B1,1))&TEXT(RIGHT(B1,LEN(B1)-1),"000-0000-0000-00"),"Invalid
Entry"))

--
John C


"John C" wrote:

Building off Ron's formula, since the cell of entry has the letter, as well
as HAS to have all the digits, even zerios, the following would work:
C1: =UPPER(LEFT(B1,1))&TEXT(RIGHT(B1,LEN(B1)-1),"000-0000-0000-00")

Assuming B1 is where the 'raw' data is entered.

--
John C


"Ron Rosenfeld" wrote:

On Wed, 16 Jul 2008 08:58:05 -0700, excel user <excel
wrote:

I need to create a custom number format for a wisconsin driver's license
number (i.e. "S123-4567-8912-34") How can this be done?


000-0000-000-00 will do for the numeric part of the number,

\S000-0000-000-00 will do for the above where the numeric part is preceded by
the letter "S". (You would just enter the numbers)

but I don't think you can have a variable preceding letter in the format.

If you put your letter in A1, and the number in B1, then perhaps:


C1: =TEXT(B1,"\"&UPPER(A1)&"000-0000-000-00")

--ron