ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   moved macros to new book, now not working (https://www.excelbanter.com/excel-programming/442045-moved-macros-new-book-now-not-working.html)

lallen

moved macros to new book, now not working
 
I thought I posted this problem last night, but I can't find it anywhere. My
apologies if I've posted it twice.

I moved some macros to a new workbook, 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.

Barb Reinhardt

moved macros to new book, now not working
 
See note BELOW
--
HTH,

Barb Reinhardt



"lallen" wrote:

I thought I posted this problem last night, but I can't find it anywhere. My
apologies if I've posted it twice.

I moved some macros to a new workbook, 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:


' What is the ACTIVEBOOK here.
'I'm betting it's not what you think it is.

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

Any suggestions would be greatly appreciated.



All times are GMT +1. The time now is 11:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com