-
呼啦一阵风
在这种情况下,我总是使用这样的代码(只要确保您选择的分度数不在搜索范围内即可)Dim tmp As StringDim arr() As StringIf Not Selection Is Nothing Then For Each cell In Selection If (cell <> "") And (InStr(tmp, cell) = 0) Then tmp = tmp & cell & "|" End If Next cellEnd IfIf Len(tmp) > 0 Then tmp = Left(tmp, Len(tmp) - 1)arr = Split(tmp, "|")
-
阿晨1998
Sub GetUniqueAndCount() Dim d As Object, c As Range, k, tmp As String Set d = CreateObject("scripting.dictionary") For Each c In Selection tmp = Trim(c.Value) If Len(tmp) > 0 Then d(tmp) = d(tmp) + 1 Next c For Each k In d.keys Debug.Print k, d(k) Next kEnd Sub
-
拉风的咖菲猫
将Tim的Dictionary方法与下面Jean-Francois的变量数组结合在一起。您想要的阵列位于 objDict.keysSub A_Unique_B()Dim XDim objDict As ObjectDim lngRow As LongSet objDict = CreateObject("Scripting.Dictionary")X = Application.Transpose(Range([a1], Cells(Rows.Count, "A").End(xlUp)))For lngRow = 1 To UBound(X, 1) objDict(X(lngRow)) = 1NextRange("B1:B" & objDict.Count) = Application.Transpose(objDict.keys)End Sub