这里的新成员试图弄清楚以下代码可能有什么问题...
我试图将行从“ A5”复制到最后一行,并将行A:L复制到C =“ Y”的列“ C&D”之外,但在执行Macro并进行调试时却什么也没得到(尽管我是新来的 :-))。任何想法或帮助将不胜感激。
Private Sub UpdateImportFile_Click()
Dim count As Long
count = WorksheetFunction.CountA(Range("A5", Range("A5").End(xlDown)))
For i = 5 To count
If Worksheets("Case Entry").Cells(i, 3).Value = "Y" Then
Worksheets("Case Entry").Rows(i).Columns(1, 2).Copy
Worksheets("Import File").Activate
Worksheets("Import File").Cells("A2").Select
ActiveSheet.PasteSpecial xlPasteValues
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("Case Entry").Cells(1, 1).Select
End Sub
答案 0 :(得分:0)
尝试一下:
Private Sub UpdateImportFile_Click()
Dim count As Long
count = WorksheetFunction.CountA(Range("A5", Range("A5").End(xlDown)))
With Worksheets("Case Entry")
For i = 5 To count + 4
If .Cells(i, 3).Value = "Y" Then
Worksheets("Import File").Cells(i, 1).Resize(1, 2).Value = .Cells(i, 1).Resize(1, 2).Value
End If
Next
End With
End Sub