Share via


NamedRange.Cut 메서드

NamedRange 컨트롤의 내용을 클립보드로 잘라내거나 지정된 대상에 붙여넣습니다.

네임스페이스:  Microsoft.Office.Tools.Excel
어셈블리:  Microsoft.Office.Tools.Excel(Microsoft.Office.Tools.Excel.dll)

구문

‘선언
Function Cut ( _
    Destination As Object _
) As Object
Object Cut(
    Object Destination
)

매개 변수

  • Destination
    형식: System.Object
    데이터를 붙여넣을 범위입니다.이 인수를 생략하면 개체는 클립보드로 잘라내집니다.

반환 값

형식: System.Object

설명

선택적 매개 변수

선택적 매개 변수에 대한 자세한 내용은 Office 솔루션의 선택적 매개 변수를 참조하십시오.

예제

다음 코드 예제에서는 Find 메서드를 사용하여 NamedRange 컨트롤에서 값이 Seashell인 첫 번째 셀을 찾습니다. 그런 다음 FindNextFindPrevious 메서드를 사용하여 값이 Seashell인 다음 셀을 찾고 원래 셀로 돌아갑니다. 끝으로, Cut 메서드를 사용하여 값이 Seashell인 첫 번째 셀의 내용을 잘라내어 셀 B1에 붙여넣습니다.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

    Private Sub FindValue()
        Me.Range("A1").Value2 = "Barnacle"
        Me.Range("A2").Value2 = "Seashell"
        Me.Range("A3").Value2 = "Star Fish"
        Me.Range("A4").Value2 = "Seashell"
        Me.Range("A5").Value2 = "Clam Shell"

        Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
            = Me.Controls.AddNamedRange(Me.Range("A1", "A5"), _
            "namedRange1")

        ' Find the first occurrence of "Seashell".
        Dim Range1 As Excel.Range = namedRange1.Find("Seashell", , , _
            Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByColumns, _
            Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, _
            False, 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.
        Dim namedRange2 As Microsoft.Office.Tools.Excel.NamedRange _
            = Me.Controls.AddNamedRange(Range1, "namedRange2")
        namedRange2.Cut(Me.Range("B1"))
    End Sub

private void FindValue()
{
    this.Range["A1", missing].Value2 = "Barnacle";
    this.Range["A2", missing].Value2 = "Seashell";
    this.Range["A3", missing].Value2 = "Star Fish";
    this.Range["A4", missing].Value2 = "Seashell";
    this.Range["A5", missing].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", missing, missing,
        Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByColumns,
        Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext,
        false, false, missing);

    // 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", missing]);
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

NamedRange 인터페이스

Microsoft.Office.Tools.Excel 네임스페이스