Partager via


XmlMappedRange.FindPrevious(Object) Méthode

Définition

public Microsoft.Office.Interop.Excel.Range FindPrevious(object After);
abstract member FindPrevious : obj -> Microsoft.Office.Interop.Excel.Range
Public Function FindPrevious (Optional After As Object) As Range

Paramètres

After
Object

Cellule avant laquelle démarrer la recherche. Cela correspond à la position de la cellule active lorsqu'une recherche est effectuée à partir de l'interface utilisateur. Notez qu’il After doit s’agir d’une seule cellule dans le XmlMappedRange contrôle. Souvenez-vous que la recherche commence avant cette cellule ; la cellule spécifiée ne fait pas l'objet d'une recherche tant que la méthode n'est pas revenue à cette cellule. Si cet argument n'est pas spécifié, la recherche démarre avant la cellule supérieure gauche du contrôle XmlMappedRange.

Retours

Range qui représente une cellule contenant les informations spécifiées.

Exemples

L’exemple de code suivant définit la valeur d’un XmlMappedRange sur la chaîne « Smith », puis utilise les Findméthodes , FindNextet FindPrevious pour rechercher la première cellule avec la chaîne « Smith ». Étant donné qu’un XmlMappedRange contient toujours exactement une cellule, la même cellule se trouve dans chaque cas. Cet exemple de code suppose que la feuille de calcul actuelle contient un XmlMappedRange nommé 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

Remarques

Recherche la cellule précédente qui correspond aux conditions spécifiées pour la Find méthode et retourne un Range objet qui représente cette cellule.

Cette méthode n’affecte pas la sélection ou la cellule active.

Paramètres facultatifs

Pour plus d’informations sur les paramètres facultatifs, consultez Paramètres facultatifs dans les solutions Office.

S’applique à