次の方法で共有


NamedRange.Clear Method

Definition

Clears the entire NamedRange control.

public:
 System::Object ^ Clear();
public object Clear ();
abstract member Clear : unit -> obj
Public Function Clear () As Object

Returns

Examples

The following code adds a note and some text to a NamedRange control and then displays a message box that prompts you to clear the cells by using the Clear method.

This example is for a document-level customization.

private void FindMarthaInTheRange()
{
    this.Range["A1"].Value2 = "Martha lives on a vineyard";

    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A2"],
        "namedRange1");

    namedRange1.AddComment("This is Martha's range.");
    namedRange1.Value2 = namedRange1.AutoComplete("Ma");

    if (MessageBox.Show("Clear the range?", "Test",
        MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        namedRange1.Clear();
    }
}
Private Sub FindMarthaInTheRange()
    Me.Range("A1").Value2 = "Martha lives on a vineyard"

    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A2"), _
        "namedRange1")

    namedRange1.AddComment("This is Martha's range.")
    namedRange1.Value2 = namedRange1.AutoComplete("Ma")

    If MessageBox.Show("Clear the range?", "Test", _
        MessageBoxButtons.YesNo) = DialogResult.Yes Then
        namedRange1.Clear()
    End If
End Sub

Applies to