Some properties of objects

As stated earlier, a property is a characteristic of an object - or a way of describing some aspect of it. When we try to describe the TV set we usually refer to its dimensions, colour, make, model, and so on. Moreover, these properties will have values associated with them, such as the size is a 28" screen, or the make might be a Sony television. In a similar way, when we describe properties of Excel objects, such as a range of cells, then properties of this object would be things like the name of the cell range, the cell width, and so on. A Range object in Excel is defined as a row, column, combination of rows and/or columns, a selection of many - not necessarily contiguous -cells, or even one cell.

Another example of an Excel object is a Workbook, and this would have properties such as the workbook name (there must be a name since it is a synonym for an Excel file), or password (i.e. a property that gives password access to the workbook). You can see from these examples that the properties of objects will differ, although there may be some in common. Each occurrence of each object has its own properties which you can look at and change. We will see how to do this later in this chapter. Examples of other properties typical VBA /Excel objects are given in Table 4.1.

Table 4.1 Summary of object properties and methods


Some properties and typical values

Some methods


Name identifies the range,for example salestodate

Column lets the user know the number of the first column in the Range object Formula shows the user the formula in a Range object

Select selects a worksheet range to work with in some way ClearContents clears data from a range of selected cells. Copy, Cut and Paste are more examples of range methods


Name identifies the worksheet. For example, Weeklysales Visible indicates whether the worksheet is visible (i.e. active) - possible values are true or false (Boolean values)

Select selects the worksheet object Delete deletes a worksheet from the currently open workbook Protect protects the active sheet from any changes.


Name identifies the workbook, for example SALESMAN.XLS ReadOnly - if true, the workbook is read only; if false, changes can be made to it File format - format of the file, e.g. .xls, xla Password - true if password protected.

Save used with this object, can be in the form Save or SaveAs: Save requires no arguments,SaveAs takes arguments such as FileName to use, Open takes the argument FileName


Name identifies the chart, for example myChart.

ChartType - the chart type, e.g. pie, bar

HasLegend makes the legend of a chart visible if set to true.

Location - a chart can be embedded in a worksheet or placed on a separate chart sheet

PlotArea refers to the colour of the plot area of a chart.

0 0

Post a comment