ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with Macro working in new workbooks that I open (https://www.excelbanter.com/excel-programming/326333-problem-macro-working-new-workbooks-i-open.html)

chris_rip

Problem with Macro working in new workbooks that I open
 
I created a Macro just using the record Macro tool. I'm analyzing data
points by graphing 600 points and also finding a slope and R-squared value of
these points. When I open excel, import the data, and run the Macro
everything works fine. However, when I save that file and open a new book
the Macro encounters a bug. I open visual basic and change the line that is
a problem from the Book1 to Book2 and click Run and the Macro works fine.
Does anyone know a way to change this to avoid this nuisance? Thanks for all
your help.

Bob Phillips[_6_]

Problem with Macro working in new workbooks that I open
 
Use Activeworkbook instead of Workbooks("Book1.xls")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"chris_rip" wrote in message
...
I created a Macro just using the record Macro tool. I'm analyzing data
points by graphing 600 points and also finding a slope and R-squared value

of
these points. When I open excel, import the data, and run the Macro
everything works fine. However, when I save that file and open a new book
the Macro encounters a bug. I open visual basic and change the line that

is
a problem from the Book1 to Book2 and click Run and the Macro works fine.
Does anyone know a way to change this to avoid this nuisance? Thanks for

all
your help.




chris_rip[_2_]

Problem with Macro working in new workbooks that I open
 
That seemed to do the trick. I'm glad to know that it was something so
simple to fix the problem. Thanks for the tip.

CR


"Bob Phillips" wrote:

Use Activeworkbook instead of Workbooks("Book1.xls")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"chris_rip" wrote in message
...
I created a Macro just using the record Macro tool. I'm analyzing data
points by graphing 600 points and also finding a slope and R-squared value

of
these points. When I open excel, import the data, and run the Macro
everything works fine. However, when I save that file and open a new book
the Macro encounters a bug. I open visual basic and change the line that

is
a problem from the Book1 to Book2 and click Run and the Macro works fine.
Does anyone know a way to change this to avoid this nuisance? Thanks for

all
your help.






All times are GMT +1. The time now is 09:02 PM.

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