View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Quick Formula question..

On Fri, 17 Jun 2005 10:30:29 -0500, DejaVu
wrote:


I'm not very good with formulas, but I'm trying to make one that will be
part of the data validation. I want it to make sure that the only thing
that the cell will accept is three alpha characters (and if not already,
make them uppercase).


You need two steps to do this.

1. Data Validation to limit your entry to three alpha characters. What
exactly do you mean by an "alpha" character? If you mean something that can be
anything that is text, then:

=AND(ISTEXT(A1),LEN(A1)=3)

If you mean A-Z and a-z only, then:

=AND(LEN(A1)=3,OR(AND(A1="A",A1<="Z"),AND(A1="a" ,A1<="z")))

Since you suggest that you want lower case letters changed to upper case after
entry, you also need an event triggered macro. The code assumes entries in
column A, so you may need to edit the AOI.

To enter this, right click on the sheet tab; select View Code; and paste the
code below into the window that opens.

Enjoy:

==============================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim AOI As Range, c As Range
Set AOI = [A:A]

Application.EnableEvents = False

If Not Intersect(Target, AOI) Is Nothing Then
For Each c In Target
c.Value = UCase(c.Value)
Next c
End If

Application.EnableEvents = True
End Sub

==========================


--ron