Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro change problem | Excel Discussion (Misc queries) | |||
Macro broken with workbook name change | Excel Discussion (Misc queries) | |||
Macro to change worksheets in the same workbook | Excel Discussion (Misc queries) | |||
Problem closing a workbook using a macro | Excel Programming | |||
A Macro to change macros? VBA problem | Excel Programming |