View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default moved macros to new book now they don't work

You had some responses at your original post.

I use google to search groups.

http://groups.google.com/advanced_se...blic.excel. *

Give it enough information (you as the author, maybe a keyword or date) and
you'll find it.

======
I don't remember you getting a definitive response, though.

And I'm not sure if anyone could.

But I'd add a line to your code for testing to see if you're processing the
correct worksheet.

With Worksheets("Sheet1")

msgbox .range("a1").address(external:=true)
.Columns("A:I").ClearContents ' does nothing
.Cells(10, 3) = "line 1" ' works
End With


That external:=true portion will show you the workbook name, worksheet name and
address ($a$1 here).

lallen wrote:

This is my third attempt to post this problem. My apologies for any
duplication.

I moved some macros to a new workbook (Excel 2003), so they could be shared
amongst multiple workbooks. In order to run the code in the new location, I
changed the worksheet_activate sub in the originating sheet as follows:

from Call Macro1("Parm1")
to Application.Run "'_Workbook2.xls'!Macro1(""Parm1"")"

Now some of the code doesn't work. For example:

With Worksheets("Sheet1")
.Columns("A:I").ClearContents ' does nothing
.Cells(10, 3) = "line 1" ' works
End With

Any suggestions would be greatly appreciated.


--

Dave Peterson