|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub MyUnion1()
T = Timer
Range("A1:A10000").SpecialCells(2).Interior.ColorIndex = 3
[e2] = Format(Timer - T, "0.00") & "秒。"
End Sub
Sub MyUnion2()
T = Timer
For i = 1 To 10
Range("A" & 1000 * (i - 1) + 1 & ":A" & i * 1000).SpecialCells(2).Interior.ColorIndex = 3
Next
[e2] = Format(Timer - T, "0.00") & "秒。"
End Sub
后者Sub MyUnion2()比前者Sub MyUnion1() 几乎快10倍 ,只需要 0.05秒
同样道理 用 UNION
For j = 1 To 10
Set rng = Nothing
For i = 1 To 1000
m = m + 1
If ar(m, 1) < 60 Then
k = k + 1
s = s & "," & "c" & m
If k Mod 30 = 0 Then
If rng Is Nothing Then
Set rng = Range(Mid(s, 2))
Else
Set rng = Union(rng, Range(Mid(s, 2)))
End If
s = ""
End If
End If
Next
If Not rng Is Nothing Then rng.Interior.ColorIndex = 3
Next
也只需要 0.11 秒,只是后面没有 兼顾到,只需要再加工而已.
[ 本帖最后由 office2008 于 2010-12-9 15:21 编辑 ] |
|