I tried using a variable inside a range with the purpose of doing the necessary rows instead of a pre-determined range.
Row = Sheets("Checklist").Range("V2").End(xlDown).Row
Parts = 4
For PN = 2 To Row
Sheets("Checklist").Range(Cells(PN, 22), Cells(PN, 24)).Copy
Sheets("Pipeline").Cells(Parts, 4).PasteSpecial
Parts = Parts + 1
Next PN
Application.CutCopyMode = False
End Sub
I receive a sheet with an order for parts. The amount of items that need to be brought over to a data base vary depending on the order.
The layout is somewhat like this:
V | W | X | |
---|---|---|---|
1 | Parts | Version | Yearly volume |
2 | 123 | A | 100 |
3 | 456 | B | 200 |
4 | 789 | C | 300 |
I tried copying line by line creating some sort of loop, in which one of you guys brought up that it's not necessary and you were right.
However, I still need to copy the whole table and bring it to the data base sheet.
For that I used the following code:
LastRow = Sheets("Checklist").Range("V2").End(xlDown).row
If Sheets("Pipeline").Range("D4") = "" Then
Parts = 4
GoTo CopyPaste
ElseIf Sheets("Pipeline").Range("D5") = "" Then
Parts = 5
GoTo CopyPaste
Else
Parts = Sheets("Pipeline").Range("D4").End(xlDown).row + 1
End If
CopyPaste:
' This is the line of code that I'm having problems, it keeps giving me an 1004 error'
->Sheets("Checklist").Range(Cells(2, 22), Cells(LastRow, 24)).Copy
Sheets("Pipeline").Cells(Parts, 4).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub