Page 152 - Excel Progamming Weekend Crash Course
P. 152

h540629 ch10.qxd  9/2/03  9:34 AM  Page 127




                  Session 10 — Using Ranges and Selections                               127

               Other Range References

               Excel and VBA provide several other useful ways to obtain references to Range objects. They
               are described in Table 10-1.


               Table 10-1  Additional Ways to Obtain Range References
               Reference                                   Returns a Range object that references
               The ActiveCell keyword                      The active cell in the currently active
                                                           worksheet.
               A Range object’s CurrentRegion property     A range bounded by (but not including)
                                                           empty rows and columns and the work-
                                                           sheet borders.

               A Worksheet object’s UsedRange property     The smallest range that contains all of
                                                           the used cells in the worksheet.


                  The CurrentRegion property can be useful. Its utility is based on the fact that the data in
               most Excel worksheets is arranged in sections, or tables, that have blank rows and columns
               between them. For example, look at the worksheet in Figure 10-3. You can see that there are
               two tables of data, separated by a blank row. With the CurrentRegion property, you can eas-
               ily define a region that includes an entire table without knowing its exact size beforehand.

































                    Figure 10-3 Excel data is often organized in tables separated by blank rows or columns.
   147   148   149   150   151   152   153   154   155   156   157