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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,040
Members
448,543
Latest member
MartinLarkin

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
Back
Top