I''ll give you some2009-08-19 23:58:15 楼主
Following is an example of using the Range property on a Range object. (In this case, the Range object is the active cell.) This example treats the Range object as if it were the upper-left cell in the worksheet, and then it enters a value of 5 into the cell that would be B2. In other words, the reference returned is relative to the upper-left corner of the Range object. Therefore, the statement that follows enters a value of 5 into the cell directly to the right and one row below the active cell:
ActiveCell.Range("B2") = 5
I said this is confusing. Fortunately, there is a much clearer way to access a cell relative to a range: the Offset property. I discuss this property after the next section.
The Cells property
Another way to reference a range is to use the Cells property. You can use the Cells property, like the Range property, on Worksheet objects and Range objects. Check the Help system, and you see that the Cells property has three syntaxes:
object.Cells(rowIndex, columnIndex)
object.Cells(rowIndex)
object.Cells
examples that demonstrate how to use the Cells property. The first example enters the value 9 into cell A1 on Sheet1. In this case, I''m using the first syntax, which accepts the index number of the row (from 1 to 1048576) and the index number of the column (from 1 to 16384):
Worksheets("Sheet1").Cells(1, 1) = 9
Here''s an example that enters the value 7 into cell D3 (that is, row 3, column 4) in the active worksheet:












