Compartilhar via


XmlMappedRange.FindNext(Object) Método

Definição

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

Parâmetros

After
Object

A célula depois da 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 no XmlMappedRange controle . Lembre-se de que a pesquisa começa depois desta célula; a célula especificada não é pesquisada até o método voltar a encapsulá-la. Se esse argumento não for especificado, a pesquisa começará após a célula do canto superior esquerdo do controle XmlMappedRange.

Retornos

Um Range que representa uma célula que contém as informações especificadas.

Exemplos

O exemplo de código a seguir define o valor de um XmlMappedRange para a cadeia de caracteres "Smith" e, em seguida, usa os Findmétodos , FindNexte FindPrevious para localizar a primeira célula com a cadeia de caracteres "Smith". Como um XmlMappedRange sempre contém exatamente uma célula, a mesma célula é encontrada em cada caso. Este exemplo de código pressupõe que a planilha atual contenha um XmlMappedRange chamado 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

Comentários

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

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

Quando a pesquisa atinge o final do intervalo de pesquisa especificado, ela é encapsulada até o início do intervalo. Para interromper uma pesquisa quando esse encapsulamento ocorrer, salve o endereço da primeira célula encontrada e, em seguida, teste cada endereço de célula encontrada com esse endereço salvo.

Parâmetros Opcionais

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

Aplica-se a