Dim i&, j&, t!, c(1 To 60000) As Long '定义c为1到60000的一维数组
t = Timer
For i = 1 To 60000
If Cells(i, 1) Mod 2 = 0 Then
j = j + 1
c(j) = Cells(i, 1) '把符合的加到数组
End If
Next i
[c1].Resize(j, 1) = Application.Transpose(c) '一维数组是横向的,故须要转排
MsgBox Timer - t
Dim i&, j&, t!, rng, c() As Long
t = Timer
rng = [a1:a60000] '先把数据放到内存数组中
For i = 1 To 60000
If rng(i, 1) Mod 2 = 0 Then
j = j + 1
ReDim Preserve c(1 To j) '因为不能预知数组大小,所以定义动态数组范围
c(j) = rng(i, 1)
End If
Next i
[d1].Resize(j, 1) = Application.Transpose(c)
MsgBox Timer - t