Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [B1]) Is Nothing Then Exit Sub
Dim cible$, chemin$, fichier, feuille$, plage As Range, lig&, col As Range, x$
cible = Right([B1], 9) 'à adapter
chemin = ThisWorkbook.Path & "\" 'à adapter
fichier = Dir(chemin & "isiTel*.xlsb") '1er fichier du dossier
feuille = "Appels"
Set plage = [D1:G10000] 'référence de la plage de recherche à adapter
lig = 2
Application.ScreenUpdating = False
Application.EnableEvents = False
While fichier <> ""
For Each col In plage.Columns
x = chemin & "[" & fichier & "]" & feuille & "'!" & col.Address
Cells(lig, 6).FormulaArray = "=MATCH(""*" & cible & """,""""&'" & x & ",0)" 'formule matricielle
If IsNumeric(CStr(Cells(lig, 6))) Then
Cells(lig, 4) = fichier
Cells(lig, 5) = feuille
Cells(lig, 7) = "=INDEX('" & x & "," & Cells(lig, 6) & ")"
Cells(lig, 7) = Cells(lig, 7).Value 'supprime la formule
Cells(lig, 7).NumberFormat = "General" 'format Standard
Cells(lig, 6) = Split(col.Address, "$")(1) & Cells(lig, 6) 'adresse qui écrase la formule
lig = lig + 1
End If
Next col
fichier = Dir 'fichier suivant
Wend
Range("D" & lig & ":G" & Rows.Count).ClearContents 'RAZ
Application.EnableEvents = True
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim chemin$, lig&, wb As Workbook
chemin = ThisWorkbook.Path & "\" 'à adapter
lig = Target.Row
On Error Resume Next
Set wb = Workbooks(CStr(Cells(lig, 4)))
If wb Is Nothing Then
Set wb = Workbooks.Open(chemin & Cells(lig, 4))
Application.EnableEvents = False
With wb.Sheets(CStr(Cells(lig, 5))).Range(Cells(lig, 6))
Application.Goto .Cells(1, 2 - .Column), True 'cadrage
.RowHeight = 55
End With
Application.EnableEvents = True
End If
If wb Is Nothing And Cells(lig, 4) <> "" And lig > 1 Then Cancel = True: MsgBox "Fichier '" & Cells(lig, 4) & "' introuvable !", 48
End Sub