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
| Option Explicit
Sub chercherValeur()
Application.ScreenUpdating = False
Dim Trouve As Range, Plage As Range
Dim Valeur_Cherchee As String, cel As Range
Dim wkA As Workbook, wkB As Workbook
Dim chemin As String, fichier As String
Dim j As Long
Application.ScreenUpdating = False
Set wkA = ThisWorkbook
chemin = "C:\Users\DELL\Desktop\développement Excel\"
fichier = "adresse dossier.xlsm"
Workbooks.Open chemin & fichier
Set wkB = ActiveWorkbook
Set Plage = wkB.Sheets("Feuil2").Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
wkA.Activate
For Each cel In wkA.Sheets("F03").Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
Valeur_Cherchee = cel.Value
Set Trouve = Plage.Cells.Find(what:=Valeur_Cherchee, LookAt:=xlWhole)
If Trouve Is Nothing Then
Cells(cel.Row, 2) = Valeur_Cherchee & " n'est pas présent dans F1 " & Plage.Address
Else
Cells(cel.Row, 2) = "valeur Existe en " & Trouve.Address
End If
Next cel
wkB.Close True
Set Plage = Nothing
Set Trouve = Nothing
Application.ScreenUpdating = True
End Sub |
Partager