Problem with VBA to Copy and Paste Rows

Match12

New Member
Joined
Apr 1, 2019
Messages
19
Office Version
  1. 2016
  2. 2010
I use this very simple code to copy and paste rows - that include merged cells, conditional formatting and some dropdowns.

VBA Code:
Sub Copy_rows()
 
  Range("A11:P11”).Copy
  Range("A12:P5000").Select
  ActiveSheet.Paste

End Sub
The idea is to copy everthing in Row 1 from A11:P11 into row 12 to 5000
Sometimes is works perfectly..other times it only copies down so far and then seem to fail to merge the cells. There is no consistency as to where it fails...other than roughly rows 1200 to 1350!
 
Try to paste one by one :) It will take forever but better than manual :D
VBA Code:
Sub Copy_rows()
  Application.ScreenUpdating = False
  For i = 12 to 5000
    Cells(i - 1, 1).Resize(1,16).Copy
    Cells(i, 1).Resize(1,16).Copy.PasteSpecial Operation:=xlPasteAll
  Next
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Sorry there wont be copy

VBA Code:
Cells(i, 1).Resize(1,16).PasteSpecial Operation:=xlPasteAll
 
Upvote 0
Or you may increase the steps like this:
VBA Code:
Sub Copy_rows()
  Application.ScreenUpdating = False
  For i = 12 to 5000 Step 454
    Cells(i - 1, 1).Resize(454,16).Copy
    Cells(i, 1).Resize(454,16).PasteSpecial Operation:=xlPasteAll
  Next
  Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:
Upvote 0
@Match12
I have removed the 'Mark as solution' tick from post #10 as your comments in that post do not provide a solution to the original question. This is to help future readers.
Note that the option is not a 'Mark as solved' or 'I don't require further help' checkmark in our forum.
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top