This is a very good article that explains that it is better to use the SheetID
(also called codename) instead of the Sheet
Name.
Quoting:
The Codename property is the internal name that Excel uses to identify
each sheet. Unlike the Worksheet.Name property, the Codename remains
the same regardless of sheet name, or sheet order.
The code name can also be changed so that it is more descriptive:
ThisWorkbook.VBProject.VBComponents("Sheet1").Name = "Revenue_Actuals"
and then
Revenue_Actuals.Range("C2").value = 10
works fine.
Using codenames (such as Sheet1.Range("C1").value
) is a good idea, however changing code names at runtime as above is not considered good practice by some developers (see for example, comments on the article of the link above).
Using the sheet index is another way to go, but I personally prefer the code name.
Finally, this article lists many ways that a sheet or workbook can be referenced.
I hope this helps!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…