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 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Sub merging_Feuil_A_B_C()
Dim i As Long, n As Long
Dim Tp
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Tp = Array("A", "B", "C")
For n = LBound(Tp) To UBound(Tp)
With Sheets(Tp(n)) 'lenomdelafeuille
For i = .Range("A" & .Rows.Count).End(xlUp).Row To 7 Step -1
If UCase(.Cells(i, 1)) = UCase(.Cells(i - 1, 1)) Then
.Cells(i - 1, 1) = ""
.Range(.Cells(i, 1), .Cells(i - 1, 1)).merge
End If
Next i
For i = .Range("B" & .Rows.Count).End(xlUp).Row To 7 Step -1
If UCase(.Cells(i, 2)) = UCase(.Cells(i - 1, 2)) Then
.Cells(i - 1, 2) = ""
.Range(.Cells(i, 2), .Cells(i - 1, 2)).merge
End If
Next i
For i = .Range("C" & .Rows.Count).End(xlUp).Row To 7 Step -1
If UCase(.Cells(i, 3)) = UCase(.Cells(i - 1, 3)) Then
.Cells(i - 1, 3) = ""
.Range(.Cells(i, 3), .Cells(i - 1, 3)).merge
End If
Next i
For i = .Cells(7, .Columns.Count).End(xlToLeft).Column To 2 Step -1
If UCase(.Cells(7, i)) = UCase(.Cells(7, i - 1)) Then
.Cells(7, i - 1) = ""
.Range(.Cells(7, i), .Cells(7, i - 1)).merge
End If
Next i
End With
Next n
End Sub |
Partager