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
| Dim i As Integer, j As Integer, m As Integer, n As Integer, R As Integer
Dim Tb, Res
m = InputBox("Colonne 1"): n = InputBox("Colonne 2")
Tb = Sheets("Feuil1").Range("B2:Y25").Value
R = UBound(Tb)
For i = 1 To R
Tb(i, m) = Tb(i, m) + Tb(i, n)
Tb(i, n) = Null
Tb(m, i) = Tb(m, i) + Tb(n, i)
Tb(n, i) = Null
Next i
ReDim Res(1 To R - 1, 1 To R - 1)
m = 0: n = 0
For i = 1 To R
j = 1
If Not IsNull(Tb(i, j)) Then
m = m + 1: n = 0
For j = 1 To R
If Not IsNull(Tb(i, j)) Then
n = n + 1
Res(m, n) = Tb(i, j)
End If
Next j
End If
Next i
With Sheets("Feuil2")
.UsedRange.Clear
.Range(.Cells(2, 2), .Cells(R, R)).Value = Res
End With |
Partager