VBA repeating copy/paste if n=32

cf89

New Member
Joined
Feb 15, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi. I'm a long time lurker but can't find a solution for this one. (I've simplified the ranges below as it's larger ranges I'm copying in practice, but getting the same issue.)

I'm copying a range from one worksheet to another as follows:
Ws1.Range("A1:Ax").Copy Ws2.Range("A:A")

where x is the last row of data.

I've noticed that I use n=32, the copied data is repeated throughout Ws2.Range("A:A"), up to the end of the sheet (e.g. row 1048576). If n is any other number, it's not repeated. For example, if n=10, only A1:A10 in Ws2 will be filled.

Can anyone please tell me what is special about n=32?

Thanks!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
There is nothing "magical" about 32, other than it goes exactly into 1048576
You should only specify the 1st cell in the paste range
VBA Code:
Ws1.Range("A1:Ax").Copy Ws2.Range("A1")
 
Upvote 0
Thank you very much! Think I'd just been lucky (or unlucky really) that none of the numbers of rows I'd been using it for previously go into 1048576, so hadn't noticed the error in my code
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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