vba中怎么去除数组中重复的数据?
比如数组={"1","2","3","4","3","2"),有没有一种方法最终得到数组("1","2","3","4")。就是把重复的部分去掉,只保留一份!!求高手支持
[最优解释]
Private Sub Command1_Click()
Dim MyOne, MyTwo
Dim i As Integer, j As Integer
MyOne = Array("1", "2", "3", "4", "2", "3")
For i = 0 To 5
MyTwo = MyOne(i)
For j = i + 1 To 5
If (MyTwo = MyOne(j)) Then
Dim newr(4)
For k = 0 To 5
If (k <> j) Then
newr(k) = MyOne(k)
End If
Next
End If
Next
Next
End Sub
Else
'不添加
End If
Next
'
If flag = 0 Then
ReDim Preserve arrayTest1(UBound(arrayTest1) + 1)
arrayTest1(UBound(arrayTest1) - 1) = arrayTest(i)
End If
End If
If i = UBound(arrayTest) - 1 Then
Exit For
End If
Next
For i = 0 To UBound(arrayTest1) - 1
MsgBox arrayTest1(i)
Next
End Sub
我自己研究出来了,不要for嵌套,那个到时候很乱,不怎么好处理。我这样貌似OK了,谢谢你的支持