renamed chart sheets

orsm6

Well-known Member
Joined
Oct 3, 2012
Messages
515
Office Version
  1. 365
Platform
  1. Windows
Hi all - at work we have a workbook containing a dashboard sheet. there are about 50 buttons there which have simple macros attached that take you to the chart sheet that's coded in the macro. we had issues in the past of the sheet name e.g. chart1 being renamed to something like chart101 and every other chart sheet along the bottom foolows suit e.g. chart102, chart103 etc etc.

I went and renamed every single sheet with something like P1, P2 etc and re-wrote the macros which took hours..... and now none of the macros work because all of the sheet names have been renamed back to chart 177, chart 178 and so on.

what is the best way around this? I feel i have another few hours work ahead of me, but I need a way to stop the renaming happening or something as this is annoying as hell.

TIA
 

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
Use the code name of the sheet in your macros instead of the sheet name. The code name will always be the same, whether the sheet name changes or not. ;)
 
Upvote 0
Use the code name of the sheet in your macros instead of the sheet name. The code name will always be the same, whether the sheet name changes or not. ;)
I'm sure i tried that.. but will certainly look at it again in case i hadn't. ta mate.
 
Upvote 0
CodeName1.PNG
CodeName2.PNG
CodeName3.PNG



Like I said, the sheet code name will normally not change, they can be, but this is not normal for everyday user.

The con to using the sheet code name is that it is read only, as far as I know, in other words, you can use the sheet code name to read data from that sheet, but you won't be able to use it to write data to that sheet.

That is easily handled by 'asking what the sheet name is' that is currently attached to the sheet code name, from then on you can use the sheet name to handle reads and writes. ;)


VBA Code:
Sheets("RenamedSheet1").Range("A1")            ' is an example of using the sheet name
Sheet1.Range("A1")                    ' is an example of using the sheet code name

VBA Code:
CurrentSheetNameForSheet1CodeName = Sheet1.Name        ' is an example of asking for the sheet name that is currently attached to code name sheet1
 
Last edited:
Upvote 0
View attachment 45401View attachment 45402View attachment 45403


Like I said, the sheet code name will normally not change, they can be, but this is not normal for everyday user.

The con to using the sheet code name is that it is read only, as far as I know, in other words, you can use the sheet code name to read data from that sheet, but you won't be able to use it to write data to that sheet.

That is easily handled by 'asking what the sheet name is' that is currently attached to the sheet code name, from then on you can use the sheet name to handle reads and writes. ;)


VBA Code:
Sheets("RenamedSheet1").Range("A1")            ' is an example of using the sheet name
Sheet1.Range("A1")                    ' is an example of using the sheet code name

VBA Code:
CurrentSheetNameForSheet1CodeName = Sheet1.Name        ' is an example of asking for the sheet name that is currently attached to code name sheet1
i've tried
Code:
sheets("chart3").activate
and with select and they both do not work. The macro is launched from a button on a different sheet to where the chart is.
 
Upvote 0
I will whip up some code for you tomorrow to test, I have to get some sleep right now.
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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