Option Explicit
Sub ExtraireEsGéo(ByVal WshCbl As Worksheet)
Dim T(), EsGéo As String, CEsGéo As Integer, LSrc As Long, LCbl As Long, C As Integer
With Feuil1.ListObjects(1)
If .ListRows.Count > 0 Then T = .DataBodyRange.Value Else ReDim T(0 To 0, 0 To 0)
CEsGéo = .ListColumns("Es. Géo").Index
End With
EsGéo = WshCbl.Name
For LSrc = 1 To UBound(T, 1)
If T(LSrc, CEsGéo) = EsGéo Then
LCbl = LCbl + 1
For C = 1 To UBound(T, 2): T(LCbl, C) = T(LSrc, C): Next C
End If
Next LSrc
TableauRetaillé(WshCbl.ListObjects(1), LMax:=LCbl) = T
End Sub
Property Let TableauRetaillé(ByVal LOt As ListObject, Optional ByVal LMax As Long = -1, TVals())
Dim Trop As Long, CMax As Long, TFml(), F As Long
If LMax < 0 Then LMax = UBound(TVals, 1)
Trop = LOt.ListRows.Count - LMax
If Trop > 0 Then
LOt.ListRows(LMax + 1).Range.Resize(Trop).Delete xlShiftUp
ElseIf Trop < 0 And LMax + Trop > 1 Then
LOt.ListRows(LMax + Trop).Range.Resize(-Trop).Insert xlShiftDown, xlFormatFromLeftOrAbove
End If
If LMax = 0 Then Exit Property
ReDim TFml(1 To LOt.ListColumns.Count)
For F = 1 To UBound(TFml)
With LOt.HeaderRowRange(2, F)
If .HasFormula Then TFml(F) = .Formula2R1C1 Else TFml(F) = Null
End With: Next F
LOt.HeaderRowRange.Offset(1).Resize(LMax).Value = TVals
For F = 1 To UBound(TFml)
If Not IsNull(TFml(F)) Then LOt.ListColumns(F).DataBodyRange.Formula2R1C1 = TFml(F)
Next F
End Property