Rechercher cellules

maval

XLDnaute Barbatruc
Bonjour,

J'ai dans une colonnes"F6" une liste de nom. J'ai sur Userform un code pour rechercher a partir de la première lettre .
Mon code:
Code:
Private Sub ComboBox1_Change()
test = 0
For i = 6 To Range("F65535").End(xlUp).Row
If Left(Cells(i, 6), 1) = ComboBox1.Text Then
Rows(i).Select
test = 1
Exit For
End If
Next i
If test = 0 Then MsgBox ("AUCUN RESULTAT")
End Sub

Mais j'ai toujours ma MsgBox qui s'ouvre sans me donné la ligne?

Je vous remercie de votre aide

Cordialement

Max
 

Pièces jointes

  • Rechercher_cellules.xlsm
    113 KB · Affichages: 43

M12

XLDnaute Accro
Bonjour,

En VBA il faut faire attention à la casse (Majuscule et Minuscule)
Code:
Private Sub ComboBox1_Change()
  Dim i As Integer
  test = 0
  For i = 6 To Range("F65535").End(xlUp).Row
    If UCase(Left(Cells(i, 6), 1)) = ComboBox1.Text Then
      'MsgBox ("Résultat trouvé: " & vbLf & Cells(i, 6) & vbLf & "en ligne " & i)
      Rows(i).Select
      test = 1
      Exit For
    End If
  Next i
' If test = 0 Then MsgBox ("AUCUN RESULTAT")

 End Sub
 

Discussions similaires

Réponses
4
Affichages
165

Statistiques des forums

Discussions
311 729
Messages
2 081 966
Membres
101 852
dernier inscrit
dthi16088