run macro on only one open workbook
The macro, in Module 1 is:
Sub PasteTotalfromADs()
Sheets("Taylor").Select
ActiveSheet.Unprotect
Range("C49:D56").Select
Selection.Copy
Range("C6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("C58:D65").Select
Application.CutCopyMode = False
ActiveSheet.protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
In the 'This Workbook' object:
Private Sub Workbook_Open()
PasteTotalfromADs
End Sub
Unfortunately, I don't know the code to specify that the macro run only on
the active workbook (ActiveWorkbook.Select??). Is that all I need? Do I
need an Exit Sub statement?
Thanks for your help
"Bob Phillips" wrote:
probably because it has a reference to that workbook.
Post the code.
--
HTH
Bob Phillips
"Pete Merenda" wrote in message
...
I have several workbooks, each with a macro (to rearrange data) that runs
"on
open". When I open a second workbook (wk2), the macro runs, then
encounters
an error when it tries to run (re-run) the macro on the first workbook
(wk1).
My goal is have the macro fire only on the workbook that I'm opening, and
then stop.
I'm curious as to why the macro on wk1 tries to run when the open event
has
not occurred. Do I need some type of command to stop the macro in wk2?
|