Cells UPPER CASE automatically

Steve_C

New Member
Joined
Aug 27, 2003
Messages
29
Hi guys,

is there any way I can format a cell so that when text is entered into it as CAPS or lower case, they are always automatically converted to UPPER CASE.

I tried the =UPPER function but this does not work as its a circular function when applying it to itself. I know I could use this function to display the desired results in another column, but I would really rather only have the one column if possible.

Sorry if this is a bit basic but I'm struggling with this one.

thanks in advance
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,526
Hi,

You could try a change event:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If UCase$(Target.Text) <> LCase$(Target.Text) Then Target.Value = UCase$(Target.Value)
End Sub

To install, right-click the sheet tab, select 'View Code' & paste above into code window
 

pauleapo

Board Regular
Joined
Nov 23, 2005
Messages
73
Sorry to post inside this topic, but it relates slightly.

How would i do the same for certain columns or a range ie A3 to A299 that i wanted a specified case?



Paul
 

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,526

ADVERTISEMENT

pauleapo said:
Sorry to post inside this topic, but it relates slightly.

How would i do the same for certain columns that i wanted a specified case?



Paul

Hi Paul,

this code only operates on columns B and C:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 2 Or Target.Column > 3 Then Exit Sub
If UCase$(Target.Text) <> LCase$(Target.Text) Then Target.Value = UCase$(Target.Value)
End Sub
 

EJ42955

Board Regular
Joined
Apr 18, 2006
Messages
101
this code only operates on columns B and C:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 2 Or Target.Column > 3 Then Exit Sub
If UCase$(Target.Text) <> LCase$(Target.Text) Then Target.Value = UCase$(Target.Value)
End Sub

I used this for Worksheet_SelectionChange, also.
Specified a single column, "AE".
And, it works great. 2 lines of code to accomplish this task is awesome.


Thanks, to al_b_cnu.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Column <> 31 Then Exit Sub
If UCase$(Target.Text) <> LCase$(Target.Text) Then Target.Value = UCase$(Target.Value)

End Sub

E J
Edited: 3/30/2007 11:22 AM
Actually, after a little further investigation, this works best...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 31 Then Target.Value = UCase$(Target.Value)

End Sub
Text is changed as soon as you exit the cell.
 

ricochetrob

Board Regular
Joined
Aug 23, 2004
Messages
67

ADVERTISEMENT

That's great!

I'm a novice so this is a novice question....

What if I wanted to apply Proper Case to column AE?
How would I write it to indicate Proper?
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
I don't think there's a function to directly do that within VBA, but you can use the WorksheetFunction Proper to achieve it:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 31 Then Target.Value = Application.WorksheetFunction.Proper(Target.Value)

End Sub
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
You'll want to use Application.EnableEvents to keep the macro from repeatedly calling itself, the following will also allow this to work with multiple cells:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range, d As Range
Set d = Intersect(Target, Columns(31))
If d Is Nothing Then Exit Sub
Application.EnableEvents = False
    For Each c In d
        c = Application.WorksheetFunction.Proper(c)
    Next
Application.EnableEvents = True
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,018
Messages
5,834,976
Members
430,331
Latest member
Syed Yasir Hannan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top