When I paste data from a filtered range the data in the rows continuously repeat in the columns to the right until the last Excel column (XFD). I am unable to determine the cause of my pasting issue. I am reusing code from a different project where code works as expected pasting only 1 instance of data. The copy/paste also works as expected when I manually paste the data, regardless of if the copying is done manually or by code. It's just the pasting that is acting differently.
In the current project, I have Filtered data in columns A to P and when I copy and paste then to another sheet all the data is continuously repeated to the right as presented in the generic example -
Copied Data:
Header A | Header B |
---|---|
a1 | b1 |
a6 | b6 |
Pasted Data:
Header A | Header B | Header C | Header D | Header E | Header F |
---|---|---|---|---|---|
a1 | b1 | a1 | b1 | a1 | b1 |
a6 | b6 | a6 | b6 | a6 | b6 |
Copy Code:
Set rngFilter = Range("A1:P3472")
rngFilter.Parent.Select
rngFilter.AutoFilter Field:13, Criteria1:="=*criteria*"
rngFilter.Parent.AutoFilter.Range.Copy
Paste Code:
Worksheets(2).Rows("16:16").Select
Selection.PasteSpecial xlPasteValues, xlPasteSpecialOperationNone, False, False