Freigeben über


NamedRange.Delete Method

Definition

Deletes a dynamically created NamedRange control and removes it from the ControlCollection.

public:
 void Delete();
public void Delete ();
abstract member Delete : unit -> unit
Public Sub Delete ()

Examples

The following code example sets a NamedRange control that includes cells A1 through A5 to random values, and then uses the Delete method to remove the NamedRange control. Note that although the NamedRange control is deleted, cells A1 through A5 retain their values.

This example is for a document-level customization.

private void DeleteRange()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A5"],
        "namedRange1");
    namedRange1.Formula = "=rand()";

    namedRange1.Delete();
}
Private Sub DeleteRange()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1", "A5"), _
        "namedRange1")
    namedRange1.Formula = "=rand()"

    namedRange1.Delete()
End Sub

Remarks

This method should only be used with a NamedRange control that is created programmatically at run time. An exception is thrown if you call this method on a NamedRange control that is added to the document at design time.

Applies to