我编写了下面的脚本,它将遍历一系列数据并从一张纸上复制并粘贴到另一张纸上,这样可以正常工作。我现在希望在粘贴数据的每一行上将工作簿名称添加到D列,但所有尝试都失败。 这就是我正在尝试的,请帮助。
For i = 6 To LastRow
If Cells(i, 1) <> "" And Cells(i, 21) = "OK" And Cells(i, 22) <> "Yes" Then
Range(Cells(i, 1), Cells(i, 4)).Select
Selection.Copy
erow = Worksheets("iForms").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Worksheets("iForms").Cells(erow, 1).PasteSpecial Paste:=xlPasteValues
Worksheets("iForms").Cells(1, 5).Value = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 5)
If Cells(i, 1) <> "" Then Cells(i, 22).Value = "Yes"
If Cells(i, 22) <> "" Then Cells(i, 23).Value = Time
If Cells(i, 23) <> "" Then Cells(i, 24).Value = Environ("UserName")
ActiveWorkbook.Save
End If
Next i