Change text to all caps

J

John

I need your help with code for changing the text within a cell to all
caps. I want to attach the code to the sub "worksheet change" event to
enable the code. For example: If someone types a lower case value into
a cell it will automatically change to uppercase.

Thank you
 
K

kkknie

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count = 1 Then
Application.EnableEvents = False
Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End If
End Sub
 
B

Bob Phillips

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
.Value = UCase(.Value)
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
G

Guest

The following will work for a single cell at a time

Private Sub Worksheet_Change(ByVal Target As Range)
a = Target.AddressLocal
Target.Value = UCase(Target.Value)

End Sub
 
Top