View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
T. Valko T. Valko is offline
external usenet poster
 
Posts: 15,768
Default format cell to accept 2 letters only

You can use data validation.

Assume the cell of interest is F1.
Select cell F1
Goto the menu DataValidation
Allow: Custom
Formula:

=AND(LEN(F1)=2,CODE(F1)64,CODE(F1)<91,CODE(RIGHT( F1))64,CODE(RIGHT(F1))<91)

OK out

However, that will allow entries like BB, XX, II.

Those are obviously not state abbreviations!

Another way is to setup a list of the allowable abbreviations in a range of
cells.

Assume you list them in the range X1:X50
Then, select cell F1
Goto the menu DataValidation
Allow: List
Source: =$X$1:$X$50
Uncheck: In-cell drop down
OK out

--
Biff
Microsoft Excel MVP


"Wanna Learn" wrote in message
...
Hello column "F" is for states and I only want the abbriviation of
each
state as follows 2 alpha charatects in upper case letters e.g. NY I
formatted the column as text but how do I do the data validation for two
2
characters and upper case letters or is there and easier way? VBA? thanks
in
advance