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
| Option Explicit
Sub SupKilDelPlus()
Dim Derlig As Long, Donnee As String
Dim NoCol As Integer, NoLig As Integer
Dim Collect As New Collection, NewVal As Integer
Dim oldLig, Cell As Range, OldVal As Integer
Derlig = Cells(Columns(1).Cells.Count, 1).End(xlUp).Row
For NoLig = Derlig To 1 Step -1
Set Cell = Range("A" & NoLig)
On Error Resume Next
Donnee = Cell & Cell.Offset(0, 1) & Cell.Offset(0, 2)
Collect.Add NoLig & ";" & Cell.Offset(0, 3), Donnee
If Err <> 0 Then
oldLig = Val(Split(Collect(Donnee), ";")(0))
OldVal = Val(Split(Collect(Donnee), ";")(1))
NewVal = CStr(OldVal + Cell.Offset(0, 3))
Cell.Offset(0, 3) = NewVal
Rows(oldLig).EntireRow.Delete
Collect.Remove Donnee
Collect.Add NoLig & ";" & NewVal, Cell.Row
End If
Err.Clear
Next
End Sub |
Partager