Bonsoir,
Je ne parviens pas à faire en sorte que mon dictionnaire ne comporte aucun doublon...
Au final lorsque je veux lister les données uniques, je me retrouve avec x fois la même donnée.
Sur quoi est-ce que je me trompe d'après vous ?
Dim bi As Worksheet, dc As Worksheet
Dim Dico
Dim tabDep As Variant
Dim lrdc&
Dim a%, cib0%, cib1%
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set bi = Worksheets("CNPN (Bilan impacts)")
Set dc = Worksheets("Données Collector")
Set Dico = CreateObject("Scripting.dictionary")
'Compter le nombre d'impacts
dc.Select
With dc
cib0 = dc.Rows("1:1").Find("NUM_IMPCT", LookIn:=xlValues, lookat:=xlWhole).Column
cib1 = dc.Rows("1:1").Find("TYP_IMPCT", LookIn:=xlValues, lookat:=xlWhole).Column
Max = Application.WorksheetFunction.Max(Columns(cib0))
lrdc = dc.Cells(Rows.Count, 2).End(xlUp).Row
tabDep = .Range(Cells(2, cib1), Cells(lrdc, cib1))
'création collection
b = 1
On Error Resume Next
For Each i In tabDep
If i <> "" Then
If Not Dico.Exists(i) Then
Dico.Add b, i
b = b + 1
End If
End If
Next i
'On Error GoTo 0
End With
'export collection dans resultat
bi.Select
With bi
.Cells(1, 2) = "Nature des Impacts"
For a = 2 To Max + 1
If Dico.Count > 0 Then
'If Dico(a) <> bi.Cells(2, a - 1) Then
bi.Cells(2, a) = Dico(a)
'End If
End If
Next a
.Cells(1, Max + 2) = "Evaluation globale de l'impact"
.Range(Cells(1, Max + 2), Cells(2, Max + 2)).Merge
.Range(Cells(1, 2), Cells(1, Max + 1)).Merge
End With
Je joins un document Excel pour mieux illustrer ma requête
Bonne soirée !