Databases Reference
In-Depth Information
FIGURE 1.3
Changing the number of sheets in a new Workbook.
No matter how many sheets are within a current Workbook, it is simple enough to add another
one. The command
Sheets.Add
will add another sheet to the active Workbook. The sheet will appear immediately preceding the
active sheet. Before anything on a sheet can be referenced or changed, it must be either implicitly
referenced or made active, or explicitly referenced using the Workbook and Worksheet names in
a defining statement. A sheet can be made into the active sheet by utilizing the commands
Sheets(1).Activate
or
Sheets(“Sheet1”).Activate
Notice that using the Sheets method, a specific sheet can be referenced in one of two ways: either by
the sheet name shown on the tab within the Workbook (by default names are Sheet1, Sheet2, …, Sheetn),
or by number. The numbers refer to the order in which the sheets were created in the Workbook.
For a new Workbook with three sheets created at startup, the one-to-one correspondence between
references is shown in Table 1.2.
A word of caution is in order when utilizing the activate method with sheets. If a Workbook
contains only one
visible
sheet, and the activate method is called on that sheet, an error will result.
TABLE 1.2
Numerical and String Correspondence
of Sheet Names
Worksheet Name
Numerical Reference
Sheet1
1
Sheet2
2
Sheet3
3
 
Search WWH ::




Custom Search