Bonjour,
Voici une solution (mettre les 2 macro dans le même module puis lancer la macro "rapprochement".
En colonne G un lettrage permet le rapprochement et en colonne F est indiquée la ligne rapprochée.
les lignes qui n'ont aucune indication sont celles qui n'ont aucune contrepartie.
Nota : Seuls les montants identiques sont rapprochés... Les regroupements ne sont pas gérés.
Option Explicit
Sub rapprochement()
Dim i%, k%, kk%, X%, Srap$, ideb#, icre#, tablo
i = Cells(Rows.Count, 1).End(xlUp)(2).Row
tablo = Range("A1:H" & i)
X = 0
For k = 2 To i - 1
ideb = IIf(tablo(k, 3) <> "", tablo(k, 3), 0)
If ideb > 0 Then
For kk = 2 To i
If tablo(kk, 7) = "" Then
If tablo(kk, 4) = ideb Then
X = X + 1
Srap = RAPX(X + 1)
Cells(k, 7) = Srap: Cells(k, 8) = kk: tablo(k, 7) = Srap
Cells(kk, 7) = Srap: Cells(kk, 8) = k: tablo(kk, 7) = Srap
Exit For
End If
End If
Next
End If
Next
For k = 2 To i - 1
If tablo(k, 7) = "" Then
icre = IIf(tablo(k, 4) <> "", tablo(k, 4), 0)
If icre > 0 Then
For kk = 2 To i
If tablo(kk, 7) = "" Then
If tablo(kk, 3) = icre Then
X = X + 1
Srap = RAPX(X + 1)
Cells(k, 7) = Srap: Cells(k, 8) = kk: tablo(k, 7) = Srap
Cells(kk, 7) = Srap: Cells(kk, 8) = k: tablo(kk, 7) = Srap
Exit For
End If
End If
Next
End If
End If
Next
End Sub
Function RAPX(ByVal X&) As String
Dim i&, j&, k&, N&, l&
X = X - 1
N = Int(X / 17576)
l = N * 17576
i = Int((X - l) / 676)
j = i * 676
k = Int((X - j - l) / 26)
RAPX = Chr$(65 + N) & Chr$(65 + i) & Chr$(65 + k) & Chr$(65 + X - l - j - k * 26)
End Function
A+