VBA筛选非重复值方法比较 作者:UNARTHUR '网页:http://club.excelhome.net/viewthread.php?tid=104741&replyID=&skin=0
代码如下: Sub 按钮1_单击() '这种方法最快 'Application.ScreenUpdating = False t = Timer Dim i&, j&, k&, p&, rng, rng1, ary() Dim arr As Range [g:g].ClearContents '清除所在页面G列的值, '为什么g:g不能修改,如:g2:g,g3:g..... p = [出入库登记!c60036].End(xlUp).Row '定义数据区域的最后一行65536 Set arr = Range("出入库登记!c1:c" & p) '为什么c1:c不能修改,如:c2:c,c3:c..... 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 '不重复值放置的区域
'为什么g1不能修改,如:g2,g3..... t1 = Timer - t MsgBox "用时:" & t1 & "秒" Application.ScreenUpdating = True End Sub
因表格有表头,所以想修改以上两处g:g和g1:g 为什么每次运行完程序后,自动计算设置变成了手动计算? 请高手们指教!
[此贴子已经被作者于2008-8-20 12:36:03编辑过] |