Expand Minimize

NamedRange.Clear Method

Clears the entire NamedRange control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Object Clear()

Return Value

Type: System.Object

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", missing].Value2 = "Martha lives on a vineyard";

    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A2", missing],
        "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();
    }
}


Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft