PDA

View Full Version : Solved: automatic convert to upper case



anandbohra
11-01-2007, 10:00 PM
Hi all
pl provide me code to convert all the values of specific range to upper case if they are not in upper case.
e.g. i want user to put scrip name in Sheet1 range ("B4:b30") the moment he enter something excel should convert the same in upper case.

Bob Phillips
11-02-2007, 01:34 AM
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B4:B30" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
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.

anandbohra
11-02-2007, 01:59 AM
thanks XLD it works