Sub test()
Dim Dic, Arr
Dim i As Long, r As Long
Dim Str As String
r = Sheet1.Range("A65536").End(xlUp).Row
If r = 2 Then Exit Sub '如果第一列没有数据那么退出程序
Set Dic = CreateObject("scripting.dictionary") '创建字典对象
For i = 2 To r '将第一列数据添加到字典的key值中
Dic(CStr(Cells(i, 5))) = ""
Next
Arr = Dic.keys '返回字典key的数组
Set Dic = Nothing '销毁对象
Str = Join(Arr, ",") '将数组中的内容显示为一字符串
MsgBox Str
End Sub