其實你代碼就等如:
Sub zz()
With Sheets("汜?")
.Range("a2:a" & .Cells(Rows.Count, 1).End(xlUp).Row).Copy Sheets("緙?").[a1]
End With
End Sub
下面我把你的代碼改為:
Sub TEST()
Dim arr 'Student()
With Sheets("學生頁")
arr = .Range("a2:a" & .Cells(Rows.Count, 1).End(xlUp).Row)
End With
'x = 1
For Each y In arr
x = x + 1
'ReDim Student(x)
'Student(x) = y
Sheets("統計").Cells(x, 1) = y
Next
End Sub作者: n7822123 時間: 2015-8-22 13:58
Sub TEST()
Dim Student()
r = Sheets("學生頁").Cells(Rows.Count, 1).End(xlUp).Row
x = 1
For Each y In Sheets("學生頁").Range("a2:a" & r)
ReDim Preserve Student(x)
Student(x) = y
Sheets("統計").Cells(x, 1) = Student(x)
x = x + 1
Next
MsgBox Student(1)
MsgBox Student(11)
End Sub作者: lpk187 時間: 2015-8-22 14:37