Método XmlMappedRange.FindNext

Continua uma pesquisa que tenha começada com o Find método.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (em Microsoft.Office.Tools.Excel.dll)

Sintaxe

'Declaração
Function FindNext ( _
    After As Object _
) As Range
Range FindNext(
    Object After
)

Parâmetros

  • After
    Tipo: System.Object
    A célula após o qual você deseja pesquisar.Isso corresponde à posição da célula ativa quando uma pesquisa é feita a partir da interface do usuário.Observe que After deve ser uma única célula a XmlMappedRange de controle.Lembre-se de que a pesquisa começa depois desta célula; a célula especificada não é pesquisada até que o método dê a volta e chegue a essa célula.Se esse argumento não for especificado, a pesquisa começará após a célula no canto superior esquerdo do XmlMappedRange de controle.

Valor de retorno

Tipo: Microsoft.Office.Interop.Excel.Range
A Range que representa uma célula contendo informações especificado.

Comentários

Localiza a próxima célula que coincida com as condições especificadas para o Find método e retorna um Range que representa a célula.

Este método não afeta a seleção ou a célula ativa.

Quando a pesquisa chega ao fim do intervalo de pesquisa especificado, ela continua até o início do intervalo. Para interromper uma pesquisa quando esse retorno ocorre, salve o endereço da primeira célula encontrada e teste cada endereço de célula encontrada sucessivo contra esse endereço salvo.

Optional Parameters

Para obter informações sobre os parâmetros opcionais, consulte Parâmetros opcionais em soluções do Office.

Exemplos

O exemplo de código a seguir define o valor de um XmlMappedRange a seqüência de caracteres "Smith" e usa o Find, FindNext, e FindPrevious métodos para localizar a primeira célula com a seqüência de caracteres "Smith". Porque um XmlMappedRange sempre contém exatamente uma célula, a mesma célula encontra-se em cada caso. Este exemplo de código pressupõe que a planilha atual contém um XmlMappedRange chamado CustomerLastNameCell.

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
private void FindSmith()
{
    this.CustomerLastNameCell.Value2 = "Smith";

    // Use Find to get the range with "Smith".
    Excel.Range range1 = this.CustomerLastNameCell.Find("Smith",
        missing, missing, missing, missing, Excel.XlSearchDirection.xlNext,
        missing, missing, missing);
    string address1 = range1.get_Address(missing, missing,
        Excel.XlReferenceStyle.xlA1, missing, missing);
    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(missing, missing, 
        Excel.XlReferenceStyle.xlA1, missing, missing);
    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(missing, missing,
        Excel.XlReferenceStyle.xlA1, missing, missing);
    MessageBox.Show("FindPrevious method found the range: " + address3);
}

Segurança do .NET Framework

Consulte também

Referência

XmlMappedRange Interface

Namespace Microsoft.Office.Tools.Excel