Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Worksheet_SelectionChange Not Firing

Code works sometimes, but no firing at times.
Any clues?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("j1:j65000")) Is Nothing
Then
If Selection.Value < "DONE" Then
Selection.Value = "DONE"
Range("A" & Selection.Row & ":j" &
Selection.Row).Interior.ColorIndex = 15
Else
Selection.Value = ""
Range("A" & Selection.Row & ":j" &
Selection.Row).Interior.ColorIndex = xlNone
End If


End If
Application.EnableEvents = True
End Sub






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Worksheet_SelectionChange Not Firing

Did you try the suggested code at your other post?

On 10/14/2010 10:12, J.W. Aldridge wrote:
Code works sometimes, but no firing at times.
Any clues?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("j1:j65000")) Is Nothing
Then
If Selection.Value< "DONE" Then
Selection.Value = "DONE"
Range("A"& Selection.Row& ":j"&
Selection.Row).Interior.ColorIndex = 15
Else
Selection.Value = ""
Range("A"& Selection.Row& ":j"&
Selection.Row).Interior.ColorIndex = xlNone
End If


End If
Application.EnableEvents = True
End Sub







--
Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Worksheet_SelectionChange Not Firing

i did the other day and it didn't work. Now, it works and the other
code has stopped.
Go figure... Thanx!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Worksheet_SelectionChange Not Firing

This is a guess.

If you're testing your code, you may have stopped the execution in the middle of
the code -- when the enableevents setting was turned off.

That means that you'll have to turn it back on for excel to start monitoring for
those events.

On 10/14/2010 11:51, J.W. Aldridge wrote:
i did the other day and it didn't work. Now, it works and the other
code has stopped.
Go figure... Thanx!


--
Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Worksheet_SelectionChange Not Firing

JW:

Are you clicking outside of a J cell before clicking back into it? The
section change event doesn't fire if you click a cell a second time once
you've already clicked on it; so if you're in H, then click on a J cell, it
fires. But then if you click the same cell, it won't; you would need to
click OUTSIDE that J cell and BACK in it (thus CHANGING the selection).

HTH

"J.W. Aldridge" wrote in message
...
Code works sometimes, but no firing at times.
Any clues?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("j1:j65000")) Is Nothing
Then
If Selection.Value < "DONE" Then
Selection.Value = "DONE"
Range("A" & Selection.Row & ":j" &
Selection.Row).Interior.ColorIndex = 15
Else
Selection.Value = ""
Range("A" & Selection.Row & ":j" &
Selection.Row).Interior.ColorIndex = xlNone
End If


End If
Application.EnableEvents = True
End Sub









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Worksheet_SelectionChange Not Firing

Besides what has been mentioned by others, I would add a test to see
if more than one cell has been selected, as this will cause an error,
in which case the event handler is disabled. Also I prefer to use
'Target' as range reference as opposed to Selection. If you are using
a Change event, Target will be different from selection!

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
Application.EnableEvents = False
If Not Application.Intersect(Target, Columns("J")) Is Nothing Then
Debug.Print Target.Address, " & ", Selection.Address
If Target.Value < "DONE" Then
Target.Value = "DONE"
Range("A" & Target.Row).Resize(1, 10).Interior.ColorIndex = 15
Else
Target.Value = ""
Range("A" & Target.Row & ":j" & Target.Row).Interior.ColorIndex =
xlNone
End If
End If
Application.EnableEvents = True
End Sub

Regards,
Per
On 14 Okt., 17:44, "CompleteNewb" wrote:
JW:

Are you clicking outside of a J cell before clicking back into it? *The
section change event doesn't fire if you click a cell a second time once
you've already clicked on it; so if you're in H, then click on a J cell, it
fires. *But then if you click the same cell, it won't; you would need to
click OUTSIDE that J cell and BACK in it (thus CHANGING the selection).

HTH

"J.W. Aldridge" wrote in message

...



Code works sometimes, but no firing at times.
Any clues?


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("j1:j65000")) Is Nothing
Then
* If Selection.Value < "DONE" Then
* *Selection.Value = "DONE"
* *Range("A" & Selection.Row & ":j" &
Selection.Row).Interior.ColorIndex = 15
* Else
* *Selection.Value = ""
* *Range("A" & Selection.Row & ":j" &
Selection.Row).Interior.ColorIndex = xlNone
* End If


End If
Application.EnableEvents = True
End Sub- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet_SelectionChange Kerri Grant Excel Programming 2 February 16th 10 02:23 PM
Worksheet_SelectionChange Gary''s Student Excel Programming 3 April 5th 06 09:46 AM
Stop Worksheet_SelectionChange event from firing? Ed Excel Programming 13 January 5th 05 12:57 PM
Worksheet_SelectionChange mangesh_yadav[_144_] Excel Programming 0 October 25th 04 12:56 PM
Worksheet_SelectionChange mangesh_yadav[_143_] Excel Programming 1 October 25th 04 11:49 AM


All times are GMT +1. The time now is 03:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"