Worksheet_SelectionChange

K

Kerri Grant

I want to create a simple update flag to show when a particular
worksheet has been updated. I only want to identify when particular
cells have been updated, and have tried the following:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim rng As Range
Set rng = Me.Range("J15:DM24")

If Not Intersect(rng, Target) Is Nothing Then
Range("C2").Value = True
End If

End Sub

The above code almost works, although it changes C2 to TRUE when any
cell in rng is selected, rather than changed. Close, but not quite
there!!

*** Sent via Developersdex http://www.developersdex.com ***
 
M

marcus

Hi Kerri

Use the Change event, this should do what you want.

Take care

Marcus

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Range("J15:DM24")

If Not Intersect(Target, rng) Is Nothing Then
Range("C2").Value = True
End If
End Sub
 
R

Ryan H

The SelectionChange Event is only fired when you Excel changes focus from one
cell to another. You need an event that will fire when any data within your
range is changed. To do this you need the Change Event. Give this code a
try. Hope this helps! If so, let me know, click "YES" below.

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Me.Range("J15:DM24"), Target) Is Nothing Then
Range("C2").Value = True
End If

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