我正在尝试让VBA删除由两个变量定义的一系列行。当例程到达Range(Cells(FirstDeletedLine, 0), Cells(LastDeletedLine, 0)).Select
的行时,我收到一条错误消息。
以下是整个代码:
FirstDeletedLine = Worksheets("Data Export").Cells(95, 2).Value
LastDeletedLine = Worksheets("Data Export").Cells(96, 2).Value
LastCopiedCell = Application.WorksheetFunction.VLookup("Copy to", Range("A:B"), 2, 0)
'
Sheets("Data Export").Visible = True
Sheets("Data Export").Select
Range(Cells(FirstDeletedLine, 0), Cells(LastDeletedLine, 0)).Select
Selection.Delete Shift:=xlUp
Range("D6:LastCopiedCell").Select
Selection.Copy
Windows("DFCB LATAM DECK.xlsx").Activate
Sheets("REVENUE - QTD v. BUD").Select
Range("B14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B13").Select
End Sub
我非常感谢你的帮助。谢谢!
答案 0 :(得分:3)
我认为您需要将其设为Range(Cells(FirstDeletedLine, 1)
(而不是0)。单元格基于1,没有第0列。