Macro breaks when file is moved

MelanieB
3StarLounger
Posts: 310
Joined: 19 Apr 2010, 16:18
Location: middle of the state of Washington

Macro breaks when file is moved

Post by MelanieB »

I created a simple macro in a workbook. I used the recorder since I don't know how to write code :)

When I created the macro, I stored it in the workbook; not in personal.

When I moved the file to a new folder, the macro doesn't work because it's looking for the file in the old folder (2020 Report of Billing). The new folder is 2021 Report of Billing.
Billing macro error.JPG
I don't know how to tell the macro that the file is in the new folder. I guess I don't understand why it is even looking at the old folder if I stored the macro in the workbook. Doesn't it follow the workbook?

Other than re-recording the macro every year when we create a new folder for the current year, how can I edit the macro so it doesn't look at the old folder anymore.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro breaks when file is moved

Post by HansV »

How do you run the macro?
- From Developer > Macros or by pressing Alt+F8?
- By clicking a command button on the worksheet, or by clicking a custom Quick Access Toolbar button?
- By pressing a keyboard shortcut assigned to the macro?
- Another way - if so, how?
Best wishes,
Hans

MelanieB
3StarLounger
Posts: 310
Joined: 19 Apr 2010, 16:18
Location: middle of the state of Washington

Re: Macro breaks when file is moved

Post by MelanieB »

I made a button on the ribbon to run it - shortcut assigned to QAT.

MelanieB
3StarLounger
Posts: 310
Joined: 19 Apr 2010, 16:18
Location: middle of the state of Washington

Re: Macro breaks when file is moved

Post by MelanieB »

But you made me think about that, so I tried it using the Developer>Macros, and it worked.
so it's the button that is pointing to the old folder.
That's an easier fix. I can recreate the button easier than I can re do the macro.

MelanieB
3StarLounger
Posts: 310
Joined: 19 Apr 2010, 16:18
Location: middle of the state of Washington

Re: Macro breaks when file is moved

Post by MelanieB »

So I just re-assigned the button on the QAT and it works. So thanks for jogging my brain.