Bagikan melalui


XmlMappedRange.FindNext(Object) Metode

Definisi

public Microsoft.Office.Interop.Excel.Range FindNext (object After);
abstract member FindNext : obj -> Microsoft.Office.Interop.Excel.Range
Public Function FindNext (Optional After As Object) As Range

Parameter

After
Object

Sel yang ingin Anda cari. Ini sesuai dengan posisi sel aktif ketika pencarian dilakukan dari antarmuka pengguna. Perhatikan bahwa After harus berupa sel tunggal dalam XmlMappedRange kontrol. Ingatlah bahwa pencarian dimulai setelah sel ini; sel yang ditentukan tidak dicari sampai metode membungkus kembali ke sel ini. Jika argumen ini tidak ditentukan, pencarian dimulai setelah sel di sudut kiri atas XmlMappedRange kontrol.

Mengembalikan

Range yang mewakili sel yang berisi informasi yang ditentukan.

Contoh

Contoh kode berikut menetapkan nilai ke XmlMappedRange string "Smith", lalu menggunakan Findmetode , FindNext, dan FindPrevious untuk menemukan sel pertama dengan string "Smith". XmlMappedRange Karena selalu berisi tepat satu sel, sel yang sama ditemukan di setiap kasus. Contoh kode ini mengasumsikan bahwa lembar kerja saat ini berisi yang XmlMappedRange bernama CustomerLastNameCell.

private void FindSmith()
{
    this.CustomerLastNameCell.Value2 = "Smith";

    // Use Find to get the range with "Smith".
    Excel.Range range1 = this.CustomerLastNameCell.Find("Smith",
        Excel.XlSearchDirection.xlNext);
    string address1 = range1.get_Address(missing, missing,
        Excel.XlReferenceStyle.xlA1);
    MessageBox.Show("Find method found the range: " + address1);

    // Use FindNext to get the range with "Smith".
    Excel.Range range2 = this.CustomerLastNameCell.FindNext(range1);
    string address2 = range2.get_Address(
        Excel.XlReferenceStyle.xlA1);
    MessageBox.Show("FindNext method found the range: " + address2);

    // Use FindPrevious to get the range with "Smith".
    Excel.Range range3 = this.CustomerLastNameCell.FindPrevious(range2);
    string address3 = range3.get_Address(
        Excel.XlReferenceStyle.xlA1);
    MessageBox.Show("FindPrevious method found the range: " + address3);
}
Private Sub FindSmith()
    Me.CustomerLastNameCell.Value2 = "Smith"

    ' Use Find to get the range with "Smith".
    Dim range1 As Excel.Range = Me.CustomerLastNameCell.Find( _
        "Smith", SearchDirection:=Excel.XlSearchDirection.xlNext)
    Dim address1 As String = range1.Address(ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
    MsgBox("Find method found the range: " & address1)

    ' Use FindNext to get the range with "Smith".
    Dim range2 As Excel.Range = Me.CustomerLastNameCell.FindNext(range1)
    Dim address2 As String = range2.Address(ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
    MsgBox("FindNext method found the range: " & address2)

    ' Use FindPrevious to get the range with "Smith".
    Dim range3 As Excel.Range = Me.CustomerLastNameCell.FindPrevious(range2)
    Dim address3 As String = range3.Address(ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
    MsgBox("FindPrevious method found the range: " & address3)
End Sub

Keterangan

Menemukan sel berikutnya yang cocok dengan kondisi yang ditentukan untuk metode dan mengembalikan yang Range mewakili sel tersebutFind.

Metode ini tidak mempengaruhi pilihan atau sel aktif.

Saat pencarian mencapai akhir rentang pencarian yang ditentukan, pencarian akan dibungkus ke awal rentang. Untuk menghentikan pencarian ketika wraparound ini terjadi, simpan alamat sel pertama yang ditemukan, lalu uji setiap alamat sel yang ditemukan berturut-turut terhadap alamat tersimpan ini.

Parameter Opsional

Untuk informasi tentang parameter opsional, lihat Parameter Opsional di Solusi Office.

Berlaku untuk