XmlMappedRange.FindNext(Object) 方法

定義

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

參數

After
Object

要在此儲存格後開始搜尋。 這個儲存格就是從使用者介面進行搜尋時的現用儲存格位置。 請注意, After 必須是 控件中的 XmlMappedRange 單一單元格。 請記住,搜尋會在這個儲存格後開始,而直到此方法繞回指定儲存格後,才會搜尋這個儲存格。 如果您未指定這個引數,則會從 XmlMappedRange 控制項左上角的儲存格後開始搜尋。

傳回

Range,表示包含指定資訊的儲存格。

範例

下列程式代碼範例會將 的值 XmlMappedRange 設定為字串 「Smith」,然後使用 FindFindNextFindPrevious 方法來尋找具有字串 「Smith」 的第一個單元格。 因為 一 XmlMappedRange 律只包含一個單元格,所以在每個案例中都會找到相同的單元格。 這個程式代碼範例假設目前的工作表包含 XmlMappedRange 名為 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

備註

尋找符合方法所指定 Find 條件的下一個儲存格,並傳回 Range 代表該儲存格的 。

此方法不會影響選取範圍或使用中格。

當搜尋到達指定搜尋範圍的結尾時,它會繞著範圍開頭。 若要在發生這個換行時停止搜尋,請儲存第一個找到儲存格的位址,然後針對這個儲存的位址測試每個連續的找到單元格位址。

選擇性參數

如需選擇性參數的資訊,請參閱 Office 方案中的選擇性參數

適用於