Upper case

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
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top