请教大侠:
Sub 按钮1_单击()
Application.ScreenUpdating = False
t = Timer
Dim i&, j&, k&, p&, rng, rng1, ary()
Dim arr As Range
[g:g].ClearContents
p = [a65536].End(xlUp).Row
Set arr = Range("a1:a" & p)
ReDim ary(1 To p, 0)
rng = arr
arr.Sort Key1:=arr(1, 1), Order1:=xlAscending, Header:=xlNo
rng1 = arr
arr = rng '请问大侠,此句用意何在? 经我调试,好像是多余啊!
ary(1, 0) = rng1(1, 1)
For i = 2 To p
If rng1(i, 1) <> rng1(i - 1, 1) Then
ary(k + 2, 0) = rng1(i, 1)
k = k + 1
End If
Next i
Range("g1:g" & p) = ary
t1 = Timer - t
MsgBox "用时:" & t1 & "秒"
Application.ScreenUpdating = True
End Sub |