Hi,
I'm creating a small spreadsheet for client data in Excel and I want it formatted a certain way, I did consider data validation but it proved to just be annoying.
I've been working on some VBA code to automatically change whatever text is typed into a cell to the correct case (ucase, lcase or proper) and while I can get it working for a single range of cells getting it to work for more is proving difficult.
This is what I have so far;
![]()
Private Sub Worksheet_change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub End If On Error GoTo ErrHandler: Select Case Target Case Range("C2:C65535") If Not Application.Intersect(Me.Range("C2:C65535"), Target) Is Nothing Then If IsNumeric(Target.Value) = False Then Application.EnableEvents = False 'Target.Value = StrConv(Target.Text, vbLowerCase) Target.Value = StrConv(Target.Text, vbUpperCase) 'Target.Value = StrConv(Target.Text, vbProperCase) Application.EnableEvents = True End If End If Case Range("D2:D65535") If Not Application.Intersect(Me.Range("D2:D65535"), Target) Is Nothing Then If IsNumeric(Target.Value) = False Then Application.EnableEvents = False 'Target.Value = StrConv(Target.Text, vbLowerCase) Target.Value = StrConv(Target.Text, vbUpperCase) 'Target.Value = StrConv(Target.Text, vbProperCase) Application.EnableEvents = True End If End If Case Range("B2:B65535") If Not Application.Intersect(Me.Range("D2:D65535"), Target) Is Nothing Then If IsNumeric(Target.Value) = False Then Application.EnableEvents = False 'Target.Value = StrConv(Target.Text, vbLowerCase) 'Target.Value = StrConv(Target.Text, vbUpperCase) Target.Value = StrConv(Target.Text, vbProperCase) Application.EnableEvents = True End If End If End Select ErrHandler: Application.EnableEvents = True End Sub











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks