I have one script which converts cell entries to upper case and goes like this:
I have another script that highlights the row and column of the selected cell, and goes like this:Private Sub Worksheet_Change(ByVal Target As Range) Dim TestRangeString As String If Target.Cells.Count > 1 Then Exit Sub End If On Error GoTo ErrHandler: TestRangeString = "B8:B100,G8:J100" If Not Application.Intersect(Range(TestRangeString), 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 ErrHandler: Application.EnableEvents = True Dim TestRangeString2 As String If Target.Cells.Count > 1 Then Exit Sub End If On Error GoTo ErrHandler2: TestRangeString2 = "C8:C100,D8:D100,E8:E100" If Not Application.Intersect(Range(TestRangeString2), 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 ErrHandler2: Application.EnableEvents = True End Sub
How do I combine the two scripts so that both the features work?Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Static rr Static cc If cc <> "" Then With Columns(cc).Interior .ColorIndex = xlNone End With With Rows(rr).Interior .ColorIndex = xlNone End With End If r = Selection.Row c = Selection.Column rr = r cc = c With Columns(c).Interior .ColorIndex = 20 .Pattern = xlSolid End With With Rows(r).Interior .ColorIndex = 20 .Pattern = xlSolid End With End Sub
Thanks in advance.
Bookmarks