Delete Method
Delete method as it applies to the Range object.
Deletes the object.
expression.Delete(Shift)
expression Required. An expression that returns one of the above objects.
Shift Optional Variant. Used only with Range objects. Specifies how to shift cells to replace deleted cells. Can be one of the following XlDeleteShiftDirection constants: xlShiftToLeft or xlShiftUp. If this argument is omitted, Microsoft Excel decides based on the shape of the range.
Delete method as it applies to the ShapeNodes object.
Deletes the object.
expression.Delete(Index)
expression Required. An expression that returns one of the above objects.
Index Required Integer.
Delete method as it applies to all other objects in the Applies To list.
Deletes the object.
expression.Delete
expression Required. An expression that returns one of the above objects.
Remarks
Deleting a Point or LegendKey object deletes the entire series.
You can delete custom document properties, but you cannot delete a built-in document property.
Example
This example deletes cells A1:D10 on Sheet1 and shifts the remaining cells to the left.
Worksheets("Sheet1").Range("A1:D10").Delete Shift:=xlShiftToLeft
This example deletes Sheet3 in the active workbook without displaying the confirmation dialog box.
Application.DisplayAlerts = False
Worksheets("Sheet3").Delete
Application.DisplayAlerts = True
This example sorts the data in the first column on Sheet1 and then deletes rows that contain duplicate data.
Worksheets("Sheet1").Range("A1").Sort _
key1:=Worksheets("Sheet1").Range("A1")
Set currentCell = Worksheets("Sheet1").Range("A1")
Do While Not IsEmpty(currentCell)
Set nextCell = currentCell.Offset(1, 0)
If nextCell.Value = currentCell.Value Then
currentCell.EntireRow.Delete
End If
Set currentCell = nextCell
Loop