Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Worksheet_Change help | Excel Discussion (Misc queries) | |||
Worksheet_Change - NEW to VBA | Excel Worksheet Functions | |||
Getting around Worksheet_Change() | Excel Worksheet Functions | |||
Problems with "Worksheet_Change" | Excel Discussion (Misc queries) | |||
Worksheet_change won't run | Excel Discussion (Misc queries) |