Exploring the Excel VBA structure
When you first create a workbook, there will be two entries in the VBAProject Project panel, and they will be Sheet1
(Sheet1
) and ThisWorkBook
, as explained in more detail here:
- Worksheets
As you add more sheets to your workbook, they will appear in the panel. They can have private subroutines (private subs) that work within the worksheet only and public subs that can be called from other worksheets or functions. They can have private
and public
functions to return values. Public routines must be called with a fully qualified worksheet name, as illustrated here:
myResult = worksheets("Sheet1").<function name>
It has several events available relating to the worksheet. The name of the sheet in this example is Sheet1
. This is the name inside the brackets and will change if you assign a new name to the tab. Sheet1
outside the brackets is the Excel name for the sheet, and this will not change. You can refer to the sheet...