我们有一个名为Refund Automation的工作簿,我们输入每日交易。我们想要提取包含条目'Archieved'的所有行,并将它们复制到'masterdata'工作簿中。此外,我们希望每天更新我们的“masterdata”工作簿,以便只将“今日存档”发布到“masterData”工作簿中。任何人都可以更正它在第2行上未定义的变量
Sub myData()
Dim LastRow As Integer, i As Integer, erow As Integer
LastRow = ActiveSheet.Range(“A” & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, 24).Value = Date And Cells(i, 25).Value = “Done” Then
Range(Cells(i, 1), Cells(i, 25)).Select
Selection.Copy
Workbooks.Open Filename:="E\Brm\By Ram Final.xlsm"
Worksheets(“Sheet3”).Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
End Sub
答案 0 :(得分:0)
只使用双引号而不是引号,它绝对正常工作。
Sub myData()
Dim LastRow As Integer, i As Integer, erow As Integer
LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, 24).Value = Date And Cells(i, 25).Value = "Done" Then
Range(Cells(i, 1), Cells(i, 25)).Select
Selection.Copy
Workbooks.Open Filename:="E:\Brm\By Ram Final.xlsm"
Worksheets("DATA").Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
End Sub