View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Custome Format Alpha

On Sun, 9 Mar 2008 11:22:00 -0700, Rick wrote:

Is there anyone out there that can tell me how to create a format that does
this:
07-108029827-A it's the A that needs to be a substitue alpa character,
because the A may have to be a B, or C, or D.

Thanks


You can't have a variable letter character as part of a cell number format,
without using a VBA Macro to actually modify the cell format.

If you are typing the characters into some cell, all at once with no spaces or
hyphens, you could use a formula in an adjacent cell to have it look the way
you want.

=TEXT(LEFT(A1,11),"00-000000000-")& RIGHT(A1,1)

You could even do some validation:

=IF(AND(ISNUMBER(-LEFT(A1,11)),ISTEXT(RIGHT(A1,1)),LEN(A1)=12),
TEXT(LEFT(A1,11),"00-000000000-")& RIGHT(A1,1),"invalid entry")

--ron