1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Sub test()
Dim Couleurs
Couleurs = Array(3, 6, 8, 9, 10, 11, 12, 45, 50, 56)
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If i > 1 Then
If Left(Cells(i, 1), 1) <> Left(Cells(i - 1, 1), 1) Then
Rows(i).Insert
Cells(i, 1).Resize(, 3).Merge
Cells(i, 1).Value = "Famille " & Left(Cells(i + 1, 1), 1) & "000"
Var = CInt(Left(Cells(i + 1, 1), 1))
Cells(i, 1).Interior.ColorIndex = Application.Index(Couleurs, CInt(Left(Cells(i + 1, 1), 1)))
End If
Else
Rows(1).Insert
Cells(1, 1).Resize(, 3).Merge
Cells(1, 1).Value = "Famille " & Left(Cells(2, 1), 1) & "000"
Cells(i, 1).Interior.ColorIndex = Application.Index(Couleurs, CInt(Left(Cells(i + 1, 1), 1)))
End If
Next i
End Sub |
Partager