Macro that Ignores Tab/Sheet Name

Bkisley

Board Regular
Joined
Jan 5, 2017
Messages
100
I have a macro that is written to pull data from a different tab. This macro will not work if/when a different user changes the name of the tab. How can I change my code to pull the same data regardless of what that tab name is.

Portion of current macro
Selection.Copy
Sheets("Financial Model").Select
Range("C14").Select


So if someone changes the tab name of Financial Model to anything other than that, the macro will not work.
What can I do to the above macro that will allow me to pull the same data from that tab regardless of the name.
When I open up the VBAProject it is called Sheet12 (Financial Model)

I have already tried to change it to ....... with no success
Selection.Copy
Sheets("Sheet12").Select
Range("C14").Select


Please help!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try this.
Code:
Sheet12.Select
 
Upvote 0
Change this...
Sheets("Financial Model").Select

To this...
Sheet12.Select


Sheet12 is the sheet's code name and that doesn't change.
 
Upvote 0
Sheet12 is the sheet's code name and that doesn't change.[/COLOR]
...unless the user physically changes the sheet's Name property via the Properties Window which one hopes they wouldn't do, of course. :wink:
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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