Worksheet change event-single column

G

Guest

I have a worksheet change event so that when information is entered into
C2:C50 it will put relative data into E2:E50. except something is not
working. It's activating for every cell change on the entire sheet.

here's what I got:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C2:C50"
On Error GoTo ws_exit:
Set OldCell = Target

Application.EnableEvents = False

If Target <> "" Then

With Target
CHANGECYCLE
End With
Else
GoTo ws_exit:
End If

Application.EnableEvents = True
ws_exit:
End Sub


The sub it goes to works as it should, but I only want it to work if the
C2:C50 is selected. What did I goof?
 
G

Guest

Sorry that was what I was trying to do to fix it (it didn't work). This is
the original.

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C2:C50"
On Error GoTo ws_exit:
Set OldCell = Target

Application.EnableEvents = False

With Target
CHANGECYCLE
End With

Application.EnableEvents = True
ws_exit:
End Sub
 
G

Guest

I knew I was forgetting something: I forgot my intersect

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C2:C50"
On Error GoTo ws_exit:
Set OldCell = Target
If Target <> "" Then
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
CHANGECYCLE
End With
End If
End If
Application.EnableEvents = True
ws_exit:
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