Bonjour , j'ai pris un code sur intenet qui effectue une recherche en colonne je voudrais l'adapter sur une ligne mais ça ne marche pas :
Une solution ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 Sub Principale() Dim Plage As Range Dim Lignes(), i As Long Dim Texte As String Dim Flag As Boolean Set Plage = Sheets("Feuil1").Range("B28:AF28") 'plage de recherche Texte = "mot" 'expression cherchée Flag = Find_Next(Plage, Texte, Lignes()) 'appel de la fonction If Flag Then 'si fonction retourne Vrai = expression trouvée dans la plage For i = LBound(Lignes) To UBound(Lignes) 'restitution des lignes correspondantes Debug.Print Lignes(i) Next i Else MsgBox "L'expression : " & Texte & " n'a pas été trouvée dans la plage : " & Plage.Address End If End Sub 'Sources : Michel_m 'http://www.lesite.net/forum/affich-31432413-importation-de-donnees-sans-doublons#9 Function Find_Next(Rng As Range, Texte As String, Tbl()) As Boolean Dim Nbre As Integer, Lig As Long, Cptr As Long Nbre = Application.CountIf(Rng, Texte) If Nbre > 0 Then ReDim Tbl(Nbre - 1) Lig = 1 For Cptr = 0 To Nbre - 1 Lig = Rng.Find(Texte, Cells(Rng.Row, Lig), xlValues).Column Tbl(Cptr) = Cells(Rng.Row, Lig).Address Next Else GoTo Absent End If Find_Next = True Exit Function Absent: Find_Next = False End Function
l 'erreur vient de la fonction FIND next , la ligne < Lig = Rng.Find(Texte, Cells(Rng.Row, Lig), xlValues).Column>
Merci , bonne journée
Partager