Método XmlMappedRange.FindNext

Uma pesquisa continua que é iniciada pelo método de Find .

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 da interface do usuário.Observe que After deve ser uma única célula no controle de XmlMappedRange .Lembre-se de que a pesquisa começa após essa célula; a célula específica não é pesquisada até que a quebra automática do método envia de volta ao redor a essa célula.Se esse argumento não for especificado, a pesquisa começa depois que a célula no canto superior esquerdo do controle de XmlMappedRange .

Valor de retorno

Tipo: Microsoft.Office.Interop.Excel.Range
Range que representa um contendo células informações especificada.

Comentários

Localiza a próxima célula que corresponde às condições especificadas para o método de Find e retorna Range que representa a célula.

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

Quando a pesquisa atingir o final do intervalo especificado de pesquisa, envolve ao redor para o início do intervalo.Para interromper uma pesquisa wraparound quando isso ocorre, salve o endereço da primeira célula encontrada, e testar em cada célula são endereço de localizar- neste endereço salvo.

Parâmetros Opcionais

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

Exemplos

O exemplo de código a seguir define o valor de XmlMappedRange a cadeia de caracteres “Smith”, e usa o Find, FindNext, os métodos e de FindPrevious para encontrar a primeira célula com a cadeia de caracteres”. “SmithPorque XmlMappedRange sempre contém exatamente de uma célula, a mesma célula é encontrada em cada caso.Este exemplo de código a seguir pressupõe que a planilha atual contiver 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",
        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);
}

Segurança do .NET Framework

Consulte também

Referência

XmlMappedRange Interface

Namespace Microsoft.Office.Tools.Excel