Upper case

  • Thread starter Thread starter Chance
  • Start date Start date
C

Chance

Is this the correct way to do upper case?
Is there a simple way like conditional formatting?
Should the Application.EnableEvents be false then back to
true? Why? Can anyone break this down for me?
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("a:j")) Is
Nothing Then
Target(1).Value = UCase(Target(1).Value)
End If
Application.EnableEvents = True
End Sub
 
Is this the correct way to do upper case?
as correct as any
Is there a simple way like conditional formatting?
no

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("a:j")) Is _
Nothing Then
Target(1).Value = UCase(Target(1).Value)
End If
Application.EnableEvents = True
End Sub

If you change a cell that passes your if test - it fires the change event
again and again and again and again

so turning off events prevents this recursive call undesirable side effect.

Regards,
Tom Ogilvy
 
Back
Top