View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default If A3=alpha numeric,"X", if A3=text,"Y", Blank

On Mon, 7 Aug 2006 05:50:24 -0600, "Gary" wrote:

Alpha Numeric = 1 Alphabet (A to Z) and 3 Numerical Digits.

Text = All text, no numbers



Assuming that when you write Text you mean only large or small letters
[A-Za-z], then, although it could be done using worksheet formulas, it's easier
using regular expressions.

Download and install Longre's free morefunc.xll add-in from
http://xcell05.free.fr (This can be easily distributed with workbooks if that
is an issue).

Then try this formula:

=IF(REGEX.COUNT(A1,"^[A-Z]\d{3}$")=1,"X",IF(REGEX.COUNT(A1,"[^A-Za-z]"),"","Y"))

The first regular expression restricts the length of the entry to four
characters. If there may be leading or trailing spaces to be ignored, the
formula will need to be modified.


--ron