vba中是否有任何内置功能可从一维数组获取唯一值?只是消除重复呢?
如果没有,那么我如何从数组中获取唯一值?
这篇文章包含2个示例。我喜欢第二个:
Sub unique() Dim arr As New Collection, a Dim aFirstArray() As Variant Dim i As Long aFirstArray() = Array("Banana", "Apple", "Orange", "Tomato", "Apple", _ "Lemon", "Lime", "Lime", "Apple") On Error Resume Next For Each a In aFirstArray arr.Add a, a Next For i = 1 To arr.Count Cells(i, 1) = arr(i) Next End Sub