LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Worksheet_Change

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet_Change help Soundman Excel Discussion (Misc queries) 3 June 30th 06 10:46 PM
Worksheet_Change - NEW to VBA [email protected] Excel Worksheet Functions 1 April 26th 06 05:44 PM
Getting around Worksheet_Change() mtowle Excel Worksheet Functions 1 October 20th 05 06:05 PM
Problems with "Worksheet_Change" konpego Excel Discussion (Misc queries) 0 July 5th 05 06:29 AM
Worksheet_change won't run Eric Excel Discussion (Misc queries) 4 March 10th 05 03:43 PM


All times are GMT +1. The time now is 03:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"