Читать книгу Excel 2019 Power Programming with VBA - Michael Alexander, Dick Kusleika - Страница 117
NOTE
ОглавлениеIn the preceding example, the argument for the Cells
property isn't limited to values between 1
and 40
. If the argument exceeds the number of cells in the range, the counting continues as if the range were taller than it actually is. Therefore, a statement like the preceding one could change the value in a cell that's outside the range A1:D10. The statement that follows, for example, changes the value in cell A11:
Range("A1:D10").Cells(41) = 2000
The third syntax for the Cells
property simply returns all cells on the referenced worksheet. Unlike the other two syntaxes, in this one, the return data isn't a single cell. This example uses the ClearContents
method on the range returned by using the Cells
property on the active worksheet. The result is that the content of every cell on the worksheet is cleared.
ActiveSheet.Cells.ClearContents