QUOTE:以下是引用lautumn在2009-12-19 12:22:00的发言: 请问怎么用字典呢? 结合搁浅学委和我师傅的代码给你写了一个字典的,去掉重复的数据 Sub test() Dim Col As Integer Dim Str As String Dim dic As Object Dim i As Integer Dim arr Set dic = CreateObject("scripting.dictionary") Col = [IV1].End(xlToLeft).Column arr = Range(Cells(1, 1), Cells(1, Col)) For i = 1 To Col If Not dic.exists(arr(1, i)) Then dic(arr(1, i)) = 1 End If Next [A65536].Resize(1, dic.Count) = dic.keys Str = "=" & Range("A65536", Cells(65536, [IV65536].End(xlToLeft).Column)).Address Stop With [B2].Validation .Delete .Add Type:=xlValidateList, Formula1:=Str End WithEnd Sub
[此贴子已经被作者于2009-12-19 14:27:44编辑过]
|