Ucase code in workbook

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
 
B

Bob Phillips

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
 

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