Capitalize text upon entry in a cell

M

Michael Lanier

Is there a macro that will capitalize text entered into a cell? Most
of the time the text will be in a range such as A1:C3. Thanks for
your help.

Michael
 
R

Rick Rothstein

My response assumes that you want to make all the letters of a cell within
the specified range upper case immediately after hitting the Enter key for
the entry in that cell.

First off, you have to decide on the range of cells to apply this
functionality to (it can't be "most of the time"... it has to be all of the
time). I'll assume for this response that the range of cells is A1:C3 as you
mentioned. Right click the tab at the bottom of the worksheet that is to
have this functionality, select View Code from the popup menu that appears
and then copy/paste the following into the code window that you were taken
to...

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1:C3")) Is Nothing Then
Application.EnableEvents = False
Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End If
End Sub

Now, go back to the work sheet and type something into any cell in the range
A1:C3... as soon as you hit the Enter key, the text you typed in will become
capitalized.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top