keep tracking sheet1 - vba

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I am adding/deleting/moving/copying sheets in one workbook. So the order of sheets get change, their names get change sometime, etc.
I have all Control buttons in Sheet1. So right now I can refer to that sheet as

Sheets(1)
Sheets("sheet1")

but lets say later on I changed the order of the sheets so it wont be sheet 1 anymore, and also change the name of all sheets so it is not sheet1 anymore. Is there any way to hard code the name of a sheet so I can always using it no matter what happen. Thank you.

Thank you.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You can use
Code:
ActiveSheet
 
Upvote 0
Thank you for your reply. But it wont be the active one once I insert different sheets (add) or when I copy sheets etc. Thanks
 
Upvote 0
If you have a button on Sheet1 & Sheet2 is active, how do you click on the button?
 
Upvote 0
Yes that is the problem. I have all buttons in sheet1 then when I insert different sheets/copy/delete/add etc the active sheet wont be sheet1 anymore. My question is there an hardcoded number or name of a sheet in excel? because in my case sheet1 can move and be sheet3 and also its name might change from sheet1 to Mysheet for example. Thanks once again.
 
Upvote 0
The sheet with the buttons (regardless of name or position) has to be the activesheet in order to click the button.
 
Upvote 0
true. Did not think about that. Thank you so much.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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