Use Worksheet object and not Sheet object
Plenty of VBA users consider Worksheets and Sheets objects synonyms. They are not.
Sheets object consists of both Worksheets and Charts. Thus, if we have charts in our Excel Workbook, we should be careful, not to use Sheets and Worksheets as synonyms.
Print the name of the first object
Section titled “Print the name of the first object”Option Explicit
Sub CheckWorksheetsDiagram()
Debug.Print Worksheets(1).Name Debug.Print Charts(1).Name Debug.Print Sheets(1).Name
End SubThe result:
Sheet1Chart1Chart1
