Compartir a través de


NamedRange.Value2 Property

Definition

Gets or sets the value of the NamedRange control.

public:
 property System::Object ^ Value2 { System::Object ^ get(); void set(System::Object ^ value); };
public object Value2 { get; set; }
member this.Value2 : obj with get, set
Public Property Value2 As Object

Property Value

The value of the NamedRange control.

Examples

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 =
        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

Remarks

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

Applies to