Macro works sporadically

  • Thread starter Thread starter Tonya Marshall
  • Start date Start date
T

Tonya Marshall

I want everything to be uppercase in the worksheet and have entered this macro:

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

It works sporadically. How do I make it work all the time?
Thank you.
 
I just tested your code on xl2002 and it worked fine in row 3 or below and
columns b:w.

BTW I find this works as good
Target = UCase(Target)
 
What does sporadic mean?

Any chance you have other code disabling events?

Maybe checking to see if target(1) is in the range to be checked:

Option Explicit

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


And I'd leave the target(1) stuff there--just in case you were changing multiple
cells.
 
Back
Top