Code
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Left_score As Integer
Dim Right_score As Integer
'Dim cell As Range
Application.ScreenUpdating = False
If Not (Application.Intersect(Target, Range("B3,A9:A34")) Is Nothing) Then
On Error GoTo safe_exit
With Target
If Not .HasFormula Then
Application.EnableEvents = False
'MsgBox 3
'If .Value <> "" Then
.Value = UCase(.Value)
'End If
Application.EnableEvents = True
End If
End With
End If
If Not (Application.Intersect(Target, Range("F9:F333")) Is Nothing) Then
On Error GoTo safe_exit
'Application.EnableEvents = False
With Target
If Not .HasFormula Then
Application.EnableEvents = False
'Application.ScreenUpdating = False
'.Value = UCase(.Value)
Left_score = Trim(Split(.Value, "-")(0))
Right_score = Trim(Split(.Value, "-")(1))
'MsgBox Left_score
'MsgBox Right_score
If (Left_score = 20 And Right_score = 0) Or (Left_score = 0 And Right_score = 20) Then
'MsgBox 1
'Application.EnableEvents = False
.Font.ColorIndex = 3
'Application.EnableEvents = True
'MsgBox 4
Else
'MsgBox 2
'Application.EnableEvents = False
.Font.ColorIndex = 1
'Application.EnableEvents = True
End If
Application.EnableEvents = True
'Application.ScreenUpdating = True
End If
End With
'Application.EnableEvents = True
End If
safe_exit:
Application.EnableEvents = True
'Application.ScreenUpdating = True
'Application.EnableEvents = True
End Sub
Display More
The first part of setting the range to Uppercase is working, but the second part of changing the font colour is not. The event is being triggered but the font color is not changing. The code runs till "Msgbox 1" but does not change the font color or display "Msgbox 4". Kindly help