R
Ron Rosenfeld
I've tried to simplify the code as best I can to illustrate the problem I don't
understand.
Apparently, if I copy data from a location on the worksheet, and then paste
this data into "Target", the worksheet_change event gets triggered. However,
if I try to write to Target.value, or even another cell, an error is generated.
1004 Application-defined or object-defined error
Here is the code:
=========================
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rRng As Range
Dim Str As String
Set rRng = Range("A1")
If Not Intersect(Target, rRng) Is Nothing Then
Application.EnableEvents = False
On Error GoTo Handler
Target.Value2 = "Processed"
Range("a12").Value = "Processed"
Application.EnableEvents = True
End If
Exit Sub
Handler:
Debug.Print Err.Number, Err.Description
Resume Next
End Sub
========================
Can someone explain to me what is going on? And if there is a way around this?
I did try setting CutCopyMode to False before doing the cell write, but that
had no affect. It neither got rid of the error, nor change the CutCopyMode!
Thanks
--ron
understand.
Apparently, if I copy data from a location on the worksheet, and then paste
this data into "Target", the worksheet_change event gets triggered. However,
if I try to write to Target.value, or even another cell, an error is generated.
1004 Application-defined or object-defined error
Here is the code:
=========================
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rRng As Range
Dim Str As String
Set rRng = Range("A1")
If Not Intersect(Target, rRng) Is Nothing Then
Application.EnableEvents = False
On Error GoTo Handler
Target.Value2 = "Processed"
Range("a12").Value = "Processed"
Application.EnableEvents = True
End If
Exit Sub
Handler:
Debug.Print Err.Number, Err.Description
Resume Next
End Sub
========================
Can someone explain to me what is going on? And if there is a way around this?
I did try setting CutCopyMode to False before doing the cell write, but that
had no affect. It neither got rid of the error, nor change the CutCopyMode!
Thanks
--ron