NamedRange.Value2 Property


Gets or sets the value of the NamedRange control.

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

object Value2 { get; set; }

Property Value

Type: System.Object

The value of the NamedRange control.

The only difference between this property and the Value property is that Value2 is not a parameterized property.

The following code example uses the Value2 property to set the value of a NamedRange to a value obtained from the AutoComplete 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 =

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

    if (MessageBox.Show("Clear the range?", "Test",
        MessageBoxButtons.YesNo) == DialogResult.Yes)
Return to top