View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Worksheet SelectionChange event


you want the CHANGE event not the SELECTIONCHANGE event.

note that if you are only monitoring certain cells
you should exit from the eventhandler as quickly as possible.

e.g. if target.count 1 then exit sub


note that if your evetn handler (or procedures called from it)
make any changes to cells you should temporarily suspend event
monitoring to prevent looping.

application.enableevents = false
'make your changes
application.enableevents = true






--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


wrote :

Hi, I have the following bit of code attached to a worksheet object:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error Resume Next
If Target = Range("job_no") Then
Application.ScreenUpdating = False
Worksheets("summary").Calculate
Call ...MyCode.....
Application.ScreenUpdating = True
End If

End Sub

This works fine when the cell called "job_no" is selected or changed,
however it also runs when some other cells, (but not all), containing
just text, no formulae, are also changed.

Can anyone suggest what may be happening. I only want it to run if the
"job_no" cell is changed/selected.

Usual TIA

Rgds