Page 187 - Microsoft Office Excel 2003 Programming Inside Out
P. 187

Part 3:  The Excel Object Model


                      Chapter 8


                    Ranges and Cells




                             Basic Range Manipulations  . . . . . . . . .161   Using Named Ranges. . . . . . . . . . . . . . . 177/
                             Referring to Ranges . . . . . . . . . . . . . . .166   Getting Data Entry Right /
                             Manipulating Groups of Cells . . . . . . . .172   the First Time. . . . . . . . . . . . . . . . . . . . . 187/



                             Before any work can be done with the information inside a workbook, you need to be able to
                             access it. You’ve already looked at accessing the larger elements of the Excel Object Model,
                             namely the Microsoft Excel application itself and workbooks and worksheets. In this chapter,
                             you will learn how to work with cells and ranges of cells.

                    Basic Range Manipulations

                             A cell is the basic working unit inside an Excel worksheet, but within the Excel Object Model,
                             a Range object is the basic working unit. You use a Range object to work with either groups of
                             cells or an individual cell.

                    Finding the Active Range

                             Although there is no ActiveRange object to use, there are other ways of working with the cur­
                             rently selected range. The most common method is to use the Selection object. The Selection
                             object will return whatever the current selected object is, whether it is a range of cells or a
                             chart. Most often it will refer to a cell or range of cells. Manipulating the Selection object lets
                             you control the actions within a cell as if you were actually performing them step by step
                             using the keyboard or mouse. For example, you could use the following code to display the
                             values in the selected cells in bold type:

                             Selection.Font.Bold = True

                             Note  Remember that active is not synonymous with selected. You can select every cell in
                             a worksheet by pressing Ctrl+A, but only one cell (usually A1 if you press Ctrl+A) is the
                             active cell.












                                                                                                       161
   182   183   184   185   186   187   188   189   190   191   192