S
scrimmy
I have the following code in a worksheet in an EXCEL 2003 file(call it
File1). It seems to work fine if I only have one EXCEL file open. If I have
another EXCEL file open(File2), the code seems to want to execute in that
file also. How to I restrict the code to File1?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("PJMdata!A1:A1")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
Range("PJMdata!J1:N1").Select
Selection.Copy
Range("PJMdata!Q2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("PJMdata!A1").Select
End If
End Sub
File1). It seems to work fine if I only have one EXCEL file open. If I have
another EXCEL file open(File2), the code seems to want to execute in that
file also. How to I restrict the code to File1?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("PJMdata!A1:A1")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
Range("PJMdata!J1:N1").Select
Selection.Copy
Range("PJMdata!Q2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("PJMdata!A1").Select
End If
End Sub