The Delete method

Clearing a range differs from deleting a range. When you delete a range, Excel shifts the remaining cells around to fill up the range you deleted.

The following example uses the Delete method to delete row 6:


When you delete a range that's not a complete row or column, Excel needs to know how to shift the cells. (To see how this works, experiment with the Excel EditODelete command.)

The following statement deletes a range and then fills the resulting gap by shifting the other cells to the left:

Range("C6:C10").Delete xlToLeft

The Delete method uses an argument that indicates how Excel should shift the remaining cells. In this case, I use a built-in constant (xlToLeft) for the argument. I could also use xlUp, another named constant.

0 0

Post a comment