Is it possible to have VB code change when the file name changes?

EdwinK

New Member
Joined
Mar 11, 2009
Messages
6
I'm new to writting VBA code and what I've done so far works great except that when I change the name of the workbook and run the process, then a debug message occurs because the original name in the code didn't change when the workbook name changed. Is there a way to link the original workbook name, referenced in the code, to change when the workbook's name is changed? I really would appreciate some help on this.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
What code is giving the error?

I would just remove the reference to the name of the workbook. Is there a reason that you have to use it?
 
Upvote 0
Hello and welcome to MrExcel.

Why not use ThisWorkbook to refer to the workbook that the code resides in.
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top