Delete Method [Excel 2003 VBA Language Reference]

Delete method as it applies to the Point object.

Deletes the series the point belongs to.

expression.Delete()

expression Required. An expression that returns a Point object.

Delete method as it applies to the Range object.

Deletes the object.

expression.Delete(Shift)

expression Required. An expression that returns a Range object.

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 ListColumn object.

Deletes the column of data in the list. Does not remove the column from the sheet. If the list is linked to a Microsoft Windows SharePoint Services site, the column cannot be removed from the server, and an error is generated.

expression.Delete()

expression Required. An expression that returns a ListColumn object.

Delete method as it applies to the ListObject object.

Deletes the ListObject object and clears the cell data from the worksheet. If the list is linked to a SharePoint site, deleting it does not affect data on the server that is running Windows SharePoint Services. Any uncommitted changes made to the local list are not sent to the SharePoint list. (There is no warning that these uncommitted changes are lost.)

expression.Delete()

expression Required. An expression that returns a ListObject object.

Delete method as it applies to the ListRow object.

Deletes the cells of the list row and shifts upward any remaining cells below the deleted row. You can delete rows in the list even when the list is linked to a SharePoint site. The list on the SharePoint site will not be updated, however, until you synchronize your changes.

expression.Delete()

expression Required. An expression that returns a ListRow object.

Delete method as it applies to the ShapeNodes object.

Deletes the object.

expression.Delete(Index)

expression Required. An expression that returns a ShapeNode object.

Index  Required Integer.

Delete method as it applies to the XmlMap object.

Removes the specified XML map from the workbook.

expression.Delete()

expression Required. An expression that returns an XmlMap object.

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 objects in the Applies To list.

Remarks

Deleting the XML map will convert all of the XML Lists to generic Lists and remove all of the single-cell mappings (with the data still remaining). In addition, the XmlMap object will be removed from the XmlMaps collection. The map and schema information will be removed from the workbook (it will no longer be persisted in the XLS file and XMLSS). Any references to the deleted object become invalid.

When you delete a Workbook or Worksheet, this method displays a dialog box that prompts the user to confirm the deletion. This dialog box is displayed by default. When called on the Workbook or Worksheet objects, the Delete method returns a Boolean value that is False if the user clicked Cancel on the dialog box or True if the user clicked Delete.

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.

You can delete cube fields only if you have created the cube fields yourself by using the CalculatedMember.Add method with the xlCalculatedSet argument.

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 a column of the worksheet specified and then deletes rows that contain duplicate data.

Sub DeleteColumnDupes(strSheetName As String, strColumnLetter As String)
    Dim strColumnRange As String
    Dim rngCurrentCell As Range
    Dim rngNextCell As Range
    
    strColumnRange = strColumnLetter & "1"
    
    Worksheets(strSheetName).Range(strColumnRange).Sort _
        Key1:=Worksheets(strSheetName).Range(strColumnRange)
    Set rngCurrentCell = Worksheets(strSheetName).Range(strColumnRange)
    Do While Not IsEmpty(rngCurrentCell)
        Set rngNextCell = rngCurrentCell.Offset(1, 0)
        If rngNextCell.Value = rngCurrentCell.Value Then
            rngCurrentCell.EntireRow.Delete
        End If
        Set rngCurrentCell = rngNextCell
    Loop
End Sub

Applies to | AllowEditRange Object | Axis Object | AxisTitle Object | CalculatedMember Object | Characters Object | Chart Object | ChartObject Object | ChartObjects Collection Object | Charts Collection | ChartTitle Object | Comment Object | CubeField Object | CustomProperty Object | CustomView Object | DataLabel Object | DataLabels Collection Object | DataTable Object | DiagramNode Object | DisplayUnitLabel Object | DownBars Object | DropLines Object | ErrorBars Object | FormatCondition Object | FormatConditions Collection Object | Gridlines Object | HiLoLines Object | HPageBreak Object | Hyperlink Object | Hyperlinks Collection | LeaderLines Object | Legend Object | LegendEntry Object | LegendKey Object | ListColumn Object | ListObject Object | ListRow Object | Name Object | OLEObject Object | OLEObjects Collection Object | Parameters Collection Object | Phonetics Collection Object | PivotField Object | PivotFormula Object | PivotItem Object | Point Object | PublishObject Object | PublishObjects Collection Object | QueryTable Object | Range Collection | RecentFile Object | Scenario Object | Series Object | SeriesLines Object | Shape Object | ShapeNodes Collection Object | ShapeRange Collection | Sheets Collection Object | SmartTag Object | SoundNote Object | Style Object | TickLabels Object | Trendline Object | UpBars Object | UserAccess Object | Validation Object | VPageBreak Object | Watch Object | Watches Collection | Worksheet Object | Worksheets Collection | XmlMap Object