Macro Name problem when I change workbook name?
Hi everyone,
Say I created a macro I named "Base" in a an excel workbook named ABC.xls Later, say I changed the file name to DEF.xls Now, when I click on the macro button to execute, I get "out of range" error and the file close! How can I make the macro name is independent of the file name; so it doesn't keep referring to the old file name? Regards, Mike |
Macro Name problem when I change workbook name?
As always, post your code for comments.
-- Don Guillett SalesAid Software "Mike" wrote in message oups.com... Hi everyone, Say I created a macro I named "Base" in a an excel workbook named ABC.xls Later, say I changed the file name to DEF.xls Now, when I click on the macro button to execute, I get "out of range" error and the file close! How can I make the macro name is independent of the file name; so it doesn't keep referring to the old file name? Regards, Mike |
Macro Name problem when I change workbook name?
See answer to previous posting.
-- Regards, Tom Ogilvy "Mike" wrote in message oups.com... Hi everyone, Say I created a macro I named "Base" in a an excel workbook named ABC.xls Later, say I changed the file name to DEF.xls Now, when I click on the macro button to execute, I get "out of range" error and the file close! How can I make the macro name is independent of the file name; so it doesn't keep referring to the old file name? Regards, Mike |
Macro Name problem when I change workbook name?
Tom,
My Macro doesn't have a code! My macro just performs few operations using Tools, Macro, Record New Macro...etc. I opened ABC.xls file and saved it as, using saveas, as DEF.xls Next, I pushed the button that my macro is linked to but gave me again an error "out of range" and the file closed! HOW can I prevent this? Thanks, Mike |
Macro Name problem when I change workbook name?
In case you can't see your other post, Jake Marx posted this and I think it
is probably what you want: Does your code look like this? Workbooks("ABC.xls").Sheets("Sheet1").Range("A1"). Value=1 If so, change it to: ThisWorkbook.Sheets("Sheet1").Range("A1").Value=1 ThisWorkbook will always return a reference to the workbook in which the VBA code resides, so you don't have to worry about name changes. -- Regards, Jake Marx MS MVP - Excel www.longhead.com "Mike" wrote in message oups.com... Tom, My Macro doesn't have a code! My macro just performs few operations using Tools, Macro, Record New Macro...etc. I opened ABC.xls file and saved it as, using saveas, as DEF.xls Next, I pushed the button that my macro is linked to but gave me again an error "out of range" and the file closed! HOW can I prevent this? Thanks, Mike |
All times are GMT +1. The time now is 09:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com