Excel VBA Run-Time Error When Pasting
I need some help with Excel VBA. I get a "runtime error '1004':
Application-defined or object-defined error" on the "Sheets("Basic
Materials").Rows(lastRow1).Paste" line when trying to paste the whole row.
I used google to try to fix it, but came up with no clear solution (most
errors seemed to be with users using the select cells command for copying
and pasting).
row_last = 100
lastRow1 = 1
lastRow2 = 1
For rowfix = 2 To (row_last - 1)
If (Sheets(1).Cells(rowfix, 4).Value = "Basic Materials") Then
Sheets(1).Rows(rowfix).Copy
Sheets("Basic Materials").Rows(lastRow1).Paste
lastRow1 = lastRow1 + 1
ElseIf (Sheets(1).Cells(rowfix, 4).Value = "Change") Then
Sheets(1).Rows(rowfix).Copy
Sheets("Change").Rows(lastRow2).Paste
lastRow2 = lastRow2 + 1
End If
Next rowfix
Any help would be much appreciated!
No comments:
Post a Comment