我从每个工作表中获取 AK 列中的数据并将其放入单个工作表中。我的代码现在正确地抓住了第一张纸,但在那之后它什么也没得到。老实说,我不知道为什么。
这是我现在的代码:
Sub compile()
Dim srcRange, destRange As Range
Dim wkSheet As Worksheet
Dim wksheet_number, lastRow As Long
wksheet_number = 1
For Each wkSheet In ThisWorkbook.Worksheets
If wksheet_number > 1 Then
lastRow = ThisWorkbook.Worksheets(wksheet_number).Cells(Rows.Count, "A").End(xlUp).Row
Set srcRange = ThisWorkbook.Worksheets(wksheet_number).Range("A2:K" & lastRow)
Set destRange = ThisWorkbook.Worksheets(1).Range("A2")
If destRange.Value = "" Then
srcRange.copy destRange
Else
Set destRange = srcRange.End(xlDown)
Set destRange = srcRange.Offset(1, 0)
'destRange.Select
srcRange.copy destRange
End If
wksheet_number = wksheet_number + 1
Else
wksheet_number = wksheet_number + 1
End If
Next wkSheet
End Sub
对缺乏评论表示歉意,这是我下次可能应该添加的内容。所以有人知道我哪里出错了吗?