Expand Minimize
This topic has not yet been rated - Rate this topic

NamedRange.Cut Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Cuts the contents of the NamedRange control to the Clipboard or pastes it into a specified destination.

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

Parameters

Destination
Type: System.Object

The range where the data should be pasted. If this argument is omitted, the object is cut to the Clipboard.

Return Value

Type: System.Object

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example uses the Find method to find the first cell with the value Seashell in a NamedRange control. The example then uses the FindNext and FindPrevious methods to find the next cell with the value Seashell and then return to the original cell. Finally, the example uses the Cut method to cut the contents of the first cell with the value Seashell and paste it into cell B1.

This example is for a document-level customization.

private void FindValue()
{
    this.Range["A1"].Value2 = "Barnacle";
    this.Range["A2"].Value2 = "Seashell";
    this.Range["A3"].Value2 = "Star Fish";
    this.Range["A4"].Value2 = "Seashell";
    this.Range["A5"].Value2 = "Clam Shell";

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

    // Find the first occurrence of "Seashell".
    Excel.Range Range1 = namedRange1.Find("Seashell",
        Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByColumns,
        Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext,
        false);

    // Find the next occurrence of "Seashell".
    Range1 = namedRange1.FindNext(Range1);

    // Return to the first occurrence of "Seashell".
    Range1 = namedRange1.FindPrevious(Range1);

    // Cut the range with the first "Seashell" and copy it to cell B1.
    Microsoft.Office.Tools.Excel.NamedRange namedRange2 =
        this.Controls.AddNamedRange(Range1, "namedRange2");
    namedRange2.Cut(this.Range["B1"]);
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.