1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Sub En_2_colonnes()
Dim kR As Long, kColor As Long
kR = 1
kColor = Cells(kR, 1).Font.Color '--- couleur de la 1ère cellule en colonne 1 --- caractéristique
'--- présentation colonnes 1 et 2
Cells.VerticalAlignment = xlTop
Columns("A:A").ColumnWidth = 20
Columns("B:B").ColumnWidth = 160
Columns("B:B").WrapText = True
'--- traitement
While Cells(kR, 1) <> ""
Debug.Print kR, Cells(kR, 1).Font.Color
Cells(kR, 1).Select
If Cells(kR, 1).Font.Color = kColor Then
'--- cellule titre
kR = kR + 1
Else
'--- cellule texte
If Cells(kR - 1, 2) = "" Then
Cells(kR - 1, 2) = Cells(kR, 1)
Else
Cells(kR - 1, 2) = Cells(kR - 1, 2) & vbCrLf & Cells(kR, 1)
End If
Rows(kR).Delete Shift:=xlUp '--- supprime la ligne
End If
Wend
End Sub |
Partager