03 excel - macro ref when copying a worksheet

cesmythe

New Member
Joined
May 1, 2011
Messages
7
I have a "master" worksheet that has a macro. When I copy and rename the worksheet, the macro reference does not change to the name of the copied worksheet. It retains the original "master" reference. When I run the macro from the new worksheet it runs the macro on the "master" worksheet as that is what is referenced in the macro.

So how do I copy a worksheet and have the macro reference the new worksheet name?

Thanks in advance.

Charlie
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Charlie

What 'macro reference' do you mean?

Is it the name of the worksheet in the code?
 
Upvote 0
It would be so much easier for us to help you if you had only posted the macro's code. But you didn't, so let me take a guess. I'm guessing your macro has some lines of code containing references like either this...

Worksheets("Master")

or like this...

Sheets("Master")

If so, try replacing all of them with this...

ActiveSheet
 
Upvote 0
That's it. So simple, thank you. I have 2 other questions which I'll post later - maybe you can help with those.

Thanks again.
Charlie
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,183
Members
452,893
Latest member
denay

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