Ucase code in workbook

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

This code worked fine for a while, then stopped working. I
put it in the Workbook SelectChange. Should it be in the
Worksheet SelectChange or does it matter. How can I insure
this code will work.
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("a:i")) Is
Nothing Then
Target(1).Value = UCase(Target(1).Value)
End If
Application.EnableEvents = True
Thanks in advance
 
Richard,

If its worksheet as opposed to worksheet it will only work for one sheet,
the sheet the code is in, rather than all.

It executes okay for me, so two thoughts occur,

- is the code in the ThisWorkbook code module
- has enableevents been switched off, Iperhaps by an error encountered
somewhere not switching it back on. To counter this, try

Application.EnableEvents = True in the immediate window
and amend the code to this
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("a:i")) Is Nothing Then
Target(1).Value = UCase(Target(1).Value)
End If

ws_exit:
Application.EnableEvents = True
End Sub
 
Back
Top