问题补充说明:Sub excel取不重复值() Dim d As Object Dim lRow As Long Dim i As Long Dim str As Variant Dim strKey As String Set d = CreateObject("scripting.dictionary") lRow = Range("R65536").End(xlUp).Row str = Range("R3:R" & lRow) For i = 1 To lRow strKey = CStr(str(i, 1)) If Not d.exists(strKey) Then d.Add strKey, strKey Range("T3").Resize(UBound(d.keys) + 1, 1) = Application.Transpose(d.keys) End If Next iEnd Sub
你是不是贴错代码了,或是贴错错误信述皇罪举息了,从你的代码来看,应该不会有下标越界错误,就算后面的For循环可能出问题,前面也有OnErrorResumeNext语句,是不可能由于运行时错误而终断的.
标签:下标,越界,错误