Voici ci-joint une solution via Macro VBA (Windows only).
Dans le code de la macro vous pouvez modifier les cellules de base/export selon votre besoin. Il y a egalement possibilité de trier le résultat si vous avez .NET 3.5 installé sur votre PC.
Ci-après le code et ci-joint votre fichier MAJ.
Option Explicit
Public Sub LancerExtraction()
With Range("A2") ' activesheet
ExtractUnique baseRng:=Range(.Cells, .End(xlDown)), toRng:=Range("K2")
End With
End Sub
Private Sub ExtractUnique(ByVal baseRng As Range, ByRef toRng As Range)
' redimensionner la range si colonne entiere
With baseRng.Worksheet
If baseRng.Rows.Count = .Rows.Count Then
Set baseRng = Range(baseRng.Item(1), .Cells(.Rows.Count, baseRng.Column).End(xlUp))
End If
End With
' extraire array en memoire
Dim baseArr As Variant
baseArr = baseRng.Value
' extraire uniques (sur premiere colonne)
Dim dict As Object: Set dict = CreateObject("scripting.dictionary")
Dim i As Long
For i = LBound(baseArr, 1) To UBound(baseArr, 1)
Set dict(baseArr(i, 1)) = Nothing
Next i
Dim outArr As Variant
outArr = dict.Keys()
' ' decommenter pour trier le resultats dans l'ordre alphabetique
' ' !!! BESOIN DE .NET 3.5 installé (arraylist)
'
' Dim arrUnique As Object: Set arrUnique = CreateObject("System.Collections.ArrayList")
' For i = 0 To dict.Count - 1
' arrUnique.Add dict.Keys()(i)
' Next i
' arrUnique.Sort
' outArr = arrUnique.ToArray
' cleanup export
If toRng.Item(1).Value <> "" Then
toRng.CurrentRegion.ClearContents
End If
' export
toRng.Resize(UBound(outArr) + 1, 1).Value = WorksheetFunction.Transpose(outArr)
End Sub