A reputable source states "...The first name for each worksheet outside the parentheses is sheet code name . In nearly all circumstances in VBA, you can use the code name anywhere you would normally use Worksheet("SheetName").
The following code shows
MsgBox "MAIN.Name OK"
MsgBox "sheet1.name error"
Have I got it wrong? Or does the reputable source have it wrong?
The following code shows
MsgBox "MAIN.Name OK"
MsgBox "sheet1.name error"
Code:
Sub check_name()
Debug.Print Worksheets("MAIN").Name
MsgBox "MAIN.Name OK"
On Error GoTo NAME_ERROR:
Debug.Print Worksheets("sheet1").Name
On Error GoTo 0
NAME_ERROR:
MsgBox "sheet1.name error"
End Sub
Have I got it wrong? Or does the reputable source have it wrong?
Last edited: