VBA for Excel - problem deleting rows
I'm trying to get VBA to delete a range of rows that are defined by two variables. I get an error message when the routine reaches the line that says Range(Cells(FirstDeletedLine, 0), Cells(LastDeletedLine, 0)).Select
.
Below is the whole code:
F开发者_开发技巧irstDeletedLine = 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
I deeply appreciate your help. Thanks!
I think you need to make it Range(Cells(FirstDeletedLine, 1)
(instead of 0). Cells is 1 based, there is no column 0.
精彩评论