Compartilhar via


Método NamedRange.FindNext

Continua uma pesquisa que é iniciada com o 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 a 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 NamedRange .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 de volta ao redor a essa célula.Se esse argumento não for especificado, a pesquisa depois que a célula no canto superior esquerdo do controle de NamedRange .

Valor de retorno

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

Comentários

Localiza a célula seguir correspondente as mesmas condições que o método de Find .

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 quando esse wraparound ocorre, salve o endereço da primeira célula encontrada, e testar em cada endereço são de localizar- célula com este 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 usa o método de Find para encontrar a primeira célula com o valor Concha de mar em um controle de NamedRange . O exemplo usa os métodos de FindNext e de FindPrevious para localizar a célula seguinte com o valor Concha de mar e retornar na célula original. Finalmente, o exemplo usa o método de Cut para recortar o conteúdo da primeira célula com o valor Concha de mar e para os cola na célula B1.

Este exemplo é para uma personalização de um documento nível.

    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

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"]);
}

Segurança do .NET Framework

Consulte também

Referência

NamedRange Interface

Namespace Microsoft.Office.Tools.Excel