|
Key Words:
|
worksheet object name -- Project Explorer -- Properties Window
|
Object Names for Worksheets
The main course shows how you can refer to worksheets with object names or with visible sheet names (see Referring to Worksheets with Code). There are advantages to using object names:
- VB Editor gives auto-list help when you use object names (see figure below).
- You can type all your sheet names in lower case and the VB Editor will automatically capitalize them (if you named them using one or more capital letters). If it doesn't capitalize them, then you probably spelled it wrong.
Tip: when naming objects or variables, it is generally a good idea to use a mix of upper and lower case letters for just this reason.
- You can change the visible sheet name to whatever you want without affecting the code; code written using an object name for the sheet will still work regardless of the visible sheet name that is used.
The methodology used in the following steps is detailed in the main course (see Referring to Worksheets with Code). If your Project pane and/or Properties pane are not showing, do a menu command View > Project Explorer and/or View > Properties Window.
Give two worksheets object names
- Open your project workbook and go to the VB Editor (Alt + F11 or other method).
- Click on the Main worksheet in the Project pane.
- In the Properties pane, click once on the "(Name)" property.
- Type "owMain", and press Enter. Note that the object name (the name that is NOT in parenthesis) changes. The "ow" prefix is a personal convention I use to refer to "object-worksheet", i.e., a worksheet object. The name that is in parenthesis in the Project pane is the visible sheet name.
- Name the Lists worksheet "owLists" using the same method.
|
Click here for feedback and questions about this chapter.
Copyright © 2006-2008 J. Donald McClenagan, PhD, ALL RIGHTS RESERVED
|
|