ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change text to all caps (https://www.excelbanter.com/excel-programming/299437-change-text-all-caps.html)

John[_85_]

Change text to all caps
 
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

kkknie[_106_]

Change text to all caps
 
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



--
Message posted from http://www.ExcelForum.com


JWolf

Change text to all caps
 
See the response to your earlier thread.

John wrote:

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


Bob Phillips[_6_]

Change text to all caps
 
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)

"John" wrote in message
om...
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




No Name

Change text to all caps
 
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
-----Original Message-----
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
.



All times are GMT +1. The time now is 11:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com