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 42 43 44 45
| Sub Analyze()
Dim LastLig As Long, i As Long, n As Long
Dim MonDico As Object
Dim Cle As String
Application.ScreenUpdating = False
With Worksheets("Feuil1")
LastLig = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("S1:S" & LastLig)
.Formula = "=H1 &""|"" & I1 &""|"" &N1"
.Value = .Value
End With
Set MonDico = CreateObject("scripting.dictionary")
For i = 1 To LastLig
Cle = .Range("S" & i).Value
If Not MonDico.Exists(Cle) Then MonDico.Add Cle, Cle
Next i
End With
n = MonDico.Count
If n > 0 Then
With Worksheets("Feuil2")
.UsedRange.Clear
With .Range("A1").Resize(n, 1)
.Value = Application.Transpose(MonDico.items)
Set MonDico = Nothing
With .Offset(0, 3)
.Formula = "=SUMPRODUCT((Feuil1!S1:S" & LastLig & "=A1)*Feuil1!K1:K" & LastLig & ")"
.Value = .Value
End With
With .Offset(0, 4)
.Formula = "=INDEX(Feuil1!P1:P" & LastLig & ",MATCH(A1,Feuil1!S1:S" & LastLig & ",0))"
.Value = .Value
End With
With .Offset(0, 5)
.Formula = "=IF(D1=E1,""OK"",""KO"")"
.Value = .Value
End With
Application.DisplayAlerts = False
.TextToColumns Destination:=.Range("A1"), DataType:=xlDelimited, Other:=True, OtherChar:="|", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1))
Application.DisplayAlerts = True
End With
End With
End If
Worksheets("Feuil1").Range("S1:S" & LastLig).ClearContents
End Sub |
Partager