Forcing capital letter

videozvideoz

Board Regular
Joined
Apr 1, 2011
Messages
51
How do I make a cell default all letters to capitals so that if someone were to type "Bacon" it would appear as "BACON" automatically? Or something like "ca 90210" would become "CA 90210"

Thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Paste the following into a sheet module:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
    Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End Sub
 
Upvote 0
Thanks but it interferred with the execution of some other VBA code I already have in there despite it being seperated off by a line. Any ideas?
 
Upvote 0
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(ActiveCell, Range("E:E,G:G,I:I, K:K, M:M, O:O, Q:Q, S:S, U:U, W:W, Y:Y, AA:AA, AC:AC")) Is Nothing Then
Range("C29").Value = Range("E5").Value
Else
Range("C29").Value = Cells(5, ActiveCell.Column).Value
End If
End Sub
 
Upvote 0
Try this (untested)
Code:
 Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
Target.Value = UCase(Target.Value)

If Intersect(ActiveCell, Range("E:E,G:G,I:I, K:K, M:M, O:O, Q:Q, S:S, U:U, W:W, Y:Y, AA:AA, AC:AC")) Is Nothing Then
Range("C29").Value = Range("E5").Value
Else
Range("C29").Value = Cells(5, ActiveCell.Column).Value
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
Right... it only forces a capital letter after I click back on the cell. For example i enter "ca 1111" in cell B1 and press return. It then only changes it to capitals when I click back on B1.
 
Upvote 0
Give this a go - separate change and selection_change events, both setting EnableEvents to False at the start of the code...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Intersect(ActiveCell, Range("E:E,G:G,I:I, K:K, M:M, O:O, Q:Q, S:S, U:U, W:W, Y:Y, AA:AA, AC:AC")) Is Nothing Then
Range("C29").Value = Range("E5").Value
Else
Range("C29").Value = Cells(5, ActiveCell.Column).Value
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
Thanks for this. It works but when I go to delete multiple cells at a time it comes up with a "type mismatch" error
 
Upvote 0
Thanks for this. It works but when I go to delete multiple cells at a time it comes up with a "type mismatch" error

Slight tweak - the won't fire if more than one cell is selected

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End Sub
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Intersect(ActiveCell, Range("E:E,G:G,I:I, K:K, M:M, O:O, Q:Q, S:S, U:U, W:W, Y:Y, AA:AA, AC:AC")) Is Nothing Then
Range("C29").Value = Range("E5").Value
Else
Range("C29").Value = Cells(5, ActiveCell.Column).Value
End If
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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