つらつら Excel VBA

私の備忘録です。

Excel VBA 重複なしのリスト作成

Dim DIC As Object , keys As Object
Dim i As Integer, temp as String
Set DIC = CreateObject("Scripting.Dictionary")

temp = "Test"

'リストに無ければ、リストと配列に追加
If Not DIC.Exists(temp) Then

    DIC.Add temp, temp '辞書に追加

End If

'確認
keys = DIC.keys
For i = 0 To DIC.Count - 1
     Debug.Print keys(i)
Next i

Set DIC = Nothing