Sheet1/Sheets(1)/Sheets("sheet1")

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I have one sheet in a workbooks, and that sheet I can call it

1) Sheet1
2) Sheets(1) or Worksheets(1)
3) Sheets("sheet1") or Worksheets("sheet1")

Sheet1, Sheets("sheet1") or Worksheets("sheet1") will always refer to that sheet no matter what except if the sheet name has been changed then only Sheet1 will refer to that sheet

Sheets(1) or Worksheets(1), will always refer to that sheet unless its tab physically move to different location.

So Sheet1 will always refer to that sheet no matter what, if name is changed or location. So I can use that name in my code to avoid any problem from changing name and location. Am I right
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Right with respect to tab name changes or tab order changes. Excel assigns code names in the format Sheetn where n = 1,2,3,.... depending on the order in which the sheet was created. It is possible to change the code name directly on the VBA Properties menu for the sheet where it's listed as (Name).
 
Last edited:
Upvote 0
wow so happy to know I can change the codeName as well. Thank you so much.
 
Upvote 0
You're welcome. I posted an edit to my initial reply while you were posting post #3 . Go back and read the edited post #2 . I had forgotten that the CodeName property of a sheet is read only. That limits changing the code name to using the VBA properties window for the sheet.
 
Upvote 0
You should use Sheets(1) as that will refer to the only sheet in the workbook even if it's tab name or codename has been changed.
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

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