Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 318
Default format cell to accept 2 letters only

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
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



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default format cell to accept 2 letters only

You can use the Validation tool on the Data menu. Select the cell(s)
whose input you want to restrict, choose Validation from the Data
menu, change the "Allow" type to Custom and enter


=AND(ISNUMBER(LEFT(F1,1))=FALSE,ISNUMBER(RIGHT(F1, 1))=FALSE,LEN(F1)=2,EXACT(F1,UPPER(F1)))

Change F1 to the cell you are validating or the first cell if you are
validating multiple cells.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Tue, 2 Dec 2008 10:57:01 -0800, Wanna Learn
wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default format cell to accept 2 letters only

Create a list of the acceptable values. You can then use Data - Validation
- List to ensure that the input is valid. The only snag is that you can not
validate that the input was upper case that way. I personally would avoid
validating for upper case as the users will find it annoying. I personally
hate validation that says "I know exactly what you did wrong but instead of
handling the problem I am going to make you go back and fix it". You could
use custom validation if you really want, but I would be inclined to just use
the Upper function to convert the value to upper case in an adjacent cell.
--
HTH...

Jim Thomlinson


"Wanna Learn" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default format cell to accept 2 letters only

Data Validation won't allow you just capital letters. Why don't you use
Vlidation and select List. Then enter the 50 abbreviations for the states
and let the user select a valid state abbreviation instead of enter the data
with the keyboard.

"Wanna Learn" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default format cell to accept 2 letters only

Data Validation won't allow you just capital letters.

Sure it will. Use EXACT in the custom formula:

EXACT(A1,UPPER(A1))


Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Tue, 2 Dec 2008 11:53:05 -0800, Joel
wrote:

Data Validation won't allow you just capital letters. Why don't you use
Vlidation and select List. Then enter the 50 abbreviations for the states
and let the user select a valid state abbreviation instead of enter the data
with the keyboard.

"Wanna Learn" wrote:

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

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default format cell to accept 2 letters only

Hi,

Make an upper case list of all possible state abbreviations. Select the
cell(s) where you want the data validation and choose Data, Validation, and
pick Custom from the Allow list. Enter the formula
=OR(EXACT(F1,$G$1:$G$50))

If you don't want to enter the list in uppercase you can use

=OR(EXACT(E1,UPPER($G$1:$G$50)))

instead

Here the first cell to in column F that I want to validate is F1 and I have
put a list of Upper case codes in the range G1:G50.

If this helps, please click the Yes button

Cheers,
Shane DEvenshire


"Wanna Learn" wrote:

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

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
format a cell to accept sentences... using return key lkconey Excel Discussion (Misc queries) 1 June 22nd 06 05:22 AM
format a cell to accept a date or a whole number trick95 Excel Discussion (Misc queries) 1 March 4th 06 01:56 PM
Format cell to accept only specific character-reject others aetzkin Excel Discussion (Misc queries) 2 December 27th 05 05:03 PM
cell format in Excel 2002 SP3 will not accept long numbers spkersh Excel Worksheet Functions 1 October 27th 05 07:22 PM
How can I format a cell to accept feet and inches and add them Jack Excel Worksheet Functions 4 November 4th 04 12:30 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"