Compartilhar via


NamedRange.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 NamedRange 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 NamedRange.

Retornos

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

Exemplos

O exemplo de código a seguir usa o Find método para localizar a primeira célula com o valor Seashell em um NamedRange controle . Em seguida, o exemplo usa os FindNext métodos e FindPrevious para localizar a próxima célula com o valor Seashell e, em seguida, retornar à célula original. Por fim, o exemplo usa o Cut método para recortar o conteúdo da primeira célula com o valor Seashell e colá-lo na célula B1.

Este exemplo destina-se a uma personalização no nível de documento.

private void FindValue()
{
    this.Range["A1"].Value2 = "Barnacle";
    this.Range["A2"].Value2 = "Seashell";
    this.Range["A3"].Value2 = "Star Fish";
    this.Range["A4"].Value2 = "Seashell";
    this.Range["A5"].Value2 = "Clam Shell";

    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A5"],
        "namedRange1");

    // Find the first occurrence of "Seashell".
    Excel.Range Range1 = namedRange1.Find("Seashell",
        Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByColumns,
        Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext,
        false);

    // Find the next occurrence of "Seashell".
    Range1 = namedRange1.FindNext(Range1);

    // Return to the first occurrence of "Seashell".
    Range1 = namedRange1.FindPrevious(Range1);

    // Cut the range with the first "Seashell" and copy it to cell B1.
    Microsoft.Office.Tools.Excel.NamedRange namedRange2 =
        this.Controls.AddNamedRange(Range1, "namedRange2");
    namedRange2.Cut(this.Range["B1"]);
}
Private Sub FindValue()
    Me.Range("A1").Value2 = "Barnacle"
    Me.Range("A2").Value2 = "Seashell"
    Me.Range("A3").Value2 = "Star Fish"
    Me.Range("A4").Value2 = "Seashell"
    Me.Range("A5").Value2 = "Clam Shell"

    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1", "A5"), _
        "namedRange1")

    ' Find the first occurrence of "Seashell".
    Dim Range1 As Excel.Range = namedRange1.Find("Seashell", , , _
        Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByColumns, _
        Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, _
        False, False, )

    ' Find the next occurrence of "Seashell".
    Range1 = namedRange1.FindNext(Range1)

    ' Return to the first occurrence of "Seashell".
    Range1 = namedRange1.FindPrevious(Range1)

    ' Cut the range with the first "Seashell" and copy it to cell B1.
    Dim namedRange2 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Range1, "namedRange2")
    namedRange2.Cut(Me.Range("B1"))
End Sub

Comentários

Localiza a próxima célula que corresponde às mesmas condições que o Find método .

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