Microsoft Office Tutorials and References
In Depth Information
Inside Out
A Better Way to Create Lists
If you check the Visual Basic Editor Help file for the ListObjects collection’s Add method, you
won’t see the .Name = namestring bit at the end. The example in the Help system
requires you to create a new object and use a much longer statement to generate the same
result. Also, if you use the Add method in the manner described in the Help system, you’ll
get error messages because the ListObject you create has no name. The Add statement in
the example might seem a bit confusing, but you can think of it as a form of the following
statement:
ListObjects(0).Name = namestring
You’re creating the member of the ListObjects collection in the same statement where you
name it, but all is well because the ListObject exists when the Visual Basic Editor encoun­
ters the Name method.
As an example of how to use the ListObjects collection’s Add method, consider the worksheet
shown in Figure 26-3, which has a series of cells that contain values to be used as column labels.
Figure 26-3. This worksheet has existing column labels and is ready for a list.
Search JabSto ::




Custom Search