Function Ressortir(ByVal Quoi, ByVal VClé, ByVal Dans, Optional ByVal Horizontal)
Dim RngAC As Range, TRés(), DansHztal As Boolean, RésuHztal As Boolean, _
D As Long, LD As Long, CD As Long, R As Long, X As Long
If TypeOf Quoi Is Range Then Quoi = Quoi.Value
If TypeOf VClé Is Range Then VClé = VClé.Value
If TypeOf Dans Is Range Then Dans = Dans.Value
Set RngAC = Application.Caller
ReDim TRés(1 To RngAC.Rows.Count, 1 To RngAC.Columns.Count)
DansHztal = UBound(Dans, 1) = 1 And UBound(Dans, 2) > 1
If VarType(Horizontal) <> vbBoolean Then RésuHztal = UBound(TRés, 1) = 1 _
And UBound(TRés, 2) > 1 Else RésuHztal = Horizontal
On Error Resume Next
For D = 1 To UBound(Dans, 1 - DansHztal)
If Dans(IIf(DansHztal, 1, D), IIf(DansHztal, D, 1)) = VClé Then
R = R + 1
For X = 1 To UBound(Quoi, IIf(DansHztal, 1, 2))
TRés(IIf(RésuHztal, X, R), IIf(RésuHztal, R, X)) _
= Quoi(IIf(DansHztal, X, D), IIf(DansHztal, D, X))
Next X: End If
Next D
While R < UBound(TRés, 1 - RésuHztal)
R = R + 1
For X = 1 To UBound(Quoi, IIf(DansHztal, 1, 2))
TRés(IIf(RésuHztal, X, R), IIf(RésuHztal, R, X)) = ""
Next X: Wend
Ressortir = TRés
End Function