Private Sub CommandButton1_Click()
Dim Message As String, num_tel As String
Dim tablo, Tablo2(), k As Long, x As Long, TabExist As Long
Message = "N° de téléphone recherché"
num_tel = InputBox(Message)
If num_tel = "" Then
MsgBox "Recherche abandonnée.", vbInformation, "Fin :"
Exit Sub
End If
With Sheets("Feuil2")
tablo = .Range("A2:D" & .Range("A65536").End(xlUp).Row)
End With
x = 0
For k = 1 To UBound(tablo)
If tablo(k, 1) = num_tel Then
ReDim Preserve Tablo2(1 To 3, x)
Tablo2(1, x) = Format(tablo(k, 2), "dd/mm/yyyy hh:mm")
Tablo2(2, x) = Format(tablo(k, 3), "hh:mm:ss")
Tablo2(3, x) = tablo(k, 4)
x = x + 1
End If
Next
On Error Resume Next
TabExist = UBound(Tablo2, 2)
On Error GoTo 0
If TabExist = 0 Then
MsgBox "Numéro introuvable.", vbCritical, "Fin de Recherhe"
Exit Sub
End If
With Sheets("Feuil1")
.Range("B2:D" & .Range("B65536").End(xlUp).Row + 1).Clear
.Range("A1").Value = num_tel
.Range("B2").Resize(UBound(Tablo2, 2) + 1, UBound(Tablo2, 1)) = Application.Transpose(Tablo2)
End With
End Sub