Sub Regroupement_sans_formats()
Dim t, nlig&, ncol%, t1, i&, j%, n&, kmax&, k&
With [A1].CurrentRegion
t = .Value2: nlig = UBound(t): ncol = UBound(t, 2)
ReDim t1(1 To nlig, 1 To ncol)
For i = 1 To nlig
For j = 2 To ncol
If t(i, j) <> "" Then Exit For
Next j
If j <= ncol Then
n = n + 1
t1(n, 1) = t(i, 1)
kmax = 0
For j = 2 To ncol
For k = i To nlig
If t(k, j) <> "" Then
t1(n, j) = t(k, j)
If k > kmax Then kmax = k
Exit For
End If
Next k
Next j
i = kmax
End If
Next i
Application.ScreenUpdating = False
If .Parent.FilterMode Then .Parent.ShowAllData 'si la feuille est filtrée
.Rows(2).Resize(n).Interior.ColorIndex = xlNone 'efface les couleurs
.Resize(n) = t1
.Rows(n + 1).Resize(Rows.Count - n - .Row + 1).Delete xlUp 'RAZ en dessous
With .Parent.UsedRange: End With 'actualise la barre de défilement verticale
End With
End Sub
Sub Regroupement_avec_formats()
Application.ScreenUpdating = False
With [A1].CurrentRegion
If .Parent.FilterMode Then .Parent.ShowAllData 'si la feuille est filtrée
.Columns(1).EntireColumn.Insert
.Columns(0).NumberFormat = "General": .Columns(0) = "=1/ISBLANK(RC[2])": .Columns(0) = .Columns(0).Value
.Columns(0).Resize(, 3).Sort .Columns(0), xlDescending, Header:=xlYes 'pour placer les cellules vides en bas
.Columns(0).EntireColumn.Delete
.Columns(3).EntireColumn.Insert
.Columns(3).NumberFormat = "General": .Columns(3) = "=1/ISBLANK(RC[1])": .Columns(3) = .Columns(3).Value
.Columns(3).Resize(, 2).Sort .Columns(3), xlDescending, Header:=xlYes 'pour placer les cellules vides en bas
.Columns(3).EntireColumn.Delete
.Columns(4).EntireColumn.Insert
.Columns(4).NumberFormat = "General": .Columns(4) = "=1/ISBLANK(RC[1])": .Columns(4) = .Columns(4).Value
.Columns(4).Resize(, 2).Sort .Columns(4), xlDescending, Header:=xlYes 'pour placer les cellules vides en bas
.Columns(4).EntireColumn.Delete
On Error Resume Next 'si aucune SpecialCell
.Columns(2).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
With .Parent.UsedRange: End With 'actualise la barre de défilement verticale
End With
End Sub