XL 2016 VBA If application

Pexcel

XLDnaute Junior
Bonjour j'ai un code qui recherche dans une plage les valeurs en doubles grâce à

Code:
   Dim Plage As Range
    Dim Cel As Range

   

   

    With Worksheets("fruits")

    
       Set Plage = .Range(.Cells(2, 9), .Cells(.Rows.Count, 9).End(xlUp))

    End With
   
   
   

   For Each Cel In Plage

If Application.CountIf(Plage, Cel.Value) > 1 Then

Comment faire pour qu'il recherche le mot CITRON ? Par exemple...
Il va falloir modifier If Application.CountIf(Plage, Cel.Value) > 1 Then en If ??????(Plage, Cel.Value) = "CITRON" Then

Je bloque merci d'avance.
 

job75

XLDnaute Barbatruc
Bonjour Pexcel, sousou,

Un peu plus élaboré :
Code:
Option Compare Text 'la casse est ignorée

Sub Recherche()
Dim col$, sep$, titre$, x$, P As Range, t, i&, n&, mes$
col = "I" 'à adapter
sep = " - " 'à adapter
titre = "Recherche en colonne " & col
x = InputBox("Entrez le texte recherché :", titre)
If x = "" Then Exit Sub
With Sheets("fruits")
    Set P = .Range("A1", .UsedRange).Columns(col)
End With
t = P.Resize(P.Rows.Count + 1) 'tableau, plus rapide, au moins 2 éléments
For i = 2 To UBound(t)
    If t(i, 1) = x Then n = n + 1: mes = mes & sep & i
Next
MsgBox "'" & x & IIf(mes <> "", "' trouvé " & n & " fois en ligne" & IIf(n > 1, "s ", " ") & Mid(mes, Len(sep) + 1), "' pas trouvé..."), , titre
End Sub
A+
 

Discussions similaires

Réponses
2
Affichages
147
Réponses
1
Affichages
242

Statistiques des forums

Discussions
312 189
Messages
2 086 035
Membres
103 104
dernier inscrit
fofana