Sub essai2()
Dim l As Long, i As Long, j As Long, pos As Long, dico As New Dictionary, d As New Dictionary, d1 As New Dictionary, item As Variant
Dim release1, release2, test As Boolean, x As String, y As String, z As String, a(), totalprn As Double, item1 As Variant
release1 = Sheet1.Range("A3:E" & Sheet1.Range("C65000").End(xlUp).Row)
release2 = Sheet1.Range("G3:K" & Sheet1.Range("I65000").End(xlUp).Row)
For i = 1 To UBound(release2)
test = False
For j = 1 To UBound(release1)
If release2(i, 3) = release1(j, 3) Then
test = True: Exit For
End If
Next j
If test = False Then
If release2(i, 1) = release2(i, 2) Then 'coresitecode = SiteCode
dico(release2(i, 1) & "-" & release2(i, 3) & "-" & release2(i, 4)) = release2(i, 1) & "-" & release2(i, 3) & "-" & release2(i, 4)
d(release2(i, 4)) = release2(i, 4) 'pour totalprn
d1(release2(i, 3)) = release2(i, 3) 'fonctionnalités
End If
End If
Next i
For Each item In d.Items
totalprn = totalprn + item
Next item
k = 1
For Each item1 In d1.Items
For Each item In dico.Items
pos = InStr(item, "-"): x = Mid(item, 1, pos - 1)
y = Mid(item, pos + 1): pos = InStr(y, "-"): y = Mid(y, 1, pos - 1)
z = Mid(item, InStrRev(item, "-") + 1)
If item1 = y Then
ReDim Preserve a(1 To 3, 1 To k)
a(1, k) = x
a(2, k) = y
a(3, k) = 1 - (totalprn - z) / totalprn
k = k + 1
End If
Next item
Next item1
a = Application.Transpose(a)
Sheet1.Range("M3").Resize(UBound(a, 1), UBound(a, 2)) = a
End Sub