Udostępnij za pośrednictwem


NamedRange.FormulaR1C1 Property (2007 System)

Gets or sets the formula for the object, using R1C1-style notation.

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public Property FormulaR1C1 As Object
'Usage
Dim instance As NamedRange 
Dim value As Object 

value = instance.FormulaR1C1

instance.FormulaR1C1 = value
[BrowsableAttribute(false)]
public Object FormulaR1C1 { get; set; }
[BrowsableAttribute(false)]
public:
property Object^ FormulaR1C1 {
    Object^ get ();
    void set (Object^ value);
}
public function get FormulaR1C1 () : Object 
public function set FormulaR1C1 (value : Object)

Property Value

Type: System.Object
The formula for the object, using R1C1-style notation.

Remarks

Using this property on a NamedRange control that contains multiple cells will cause an exception to be thrown.

If the cell contains a constant, this property returns the constant. If the cell is empty, this property returns an empty string. If the cell contains a formula, this property returns the formula as a string, in the same format in which it would be displayed in the formula bar (including the equal sign).

If you set the value or formula of a cell to a date, Microsoft Office Excel checks to see whether that cell is already formatted with one of the date or time number formats. If not, the number format is changed to the default short date number format.

If the range is a one-dimensional or two-dimensional range, you can set the formula to an array of the same dimensions. Similarly, you can put the formula into an array.

Examples

The following code example creates a NamedRange and then uses the FormulaR1C1 property to set the value of the NamedRange to equal the square root of cell A1, as specified using R1C1 notation.

This example is for a document-level customization.

Private formulaR1C1Range As Microsoft.Office.Tools.Excel.NamedRange

Private Sub SetFormulaR1C1()
    formulaR1C1Range = Me.Controls.AddNamedRange( _
        Me.Range("B1"), "formulaR1C1Range")
    Me.Range("A1").Value2 = 1185921
    Me.formulaR1C1Range.FormulaR1C1 = "=SQRT(R1C1)"
    formulaR1C1Range.Select()
End Sub
Microsoft.Office.Tools.Excel.NamedRange formulaR1C1Range;
private void SetFormulaR1C1()
{
    formulaR1C1Range = this.Controls.AddNamedRange(
        this.Range["B1", missing], "formulaR1C1Range");
    this.Range["A1", missing].Value2 = 1185921;
    this.formulaR1C1Range.FormulaR1C1 = "=SQRT(R1C1)";
    formulaR1C1Range.Select();
}

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace