好的,这是我的代码,我很确定错误来自一些愚蠢的东西命名方式。我刚开始学习 VBA,所以完全不了解这个问题,无法发现问题所在。任何输入将不胜感激。
Sub test()
Dim wsInput As Worksheet: Set wsInput = ActiveSheet
Dim wsOutput As Worksheet: Set wsOutput = Workbooks.Open("C:\output.xls").Sheets(1)
Dim OutputRowCount As Integer: OutputRowCount = 1
For i = 1 To 10000
If wsInput.Range("a12" & i) <> "" Then
wsInput.Range("D12" & i, "E12" & i).Copy
wsOutput.Range("A4" & OutputRowCount).PasteSpecial Paste:=xlPasteValues
End If
Next
End Sub