Copy Range of Cells And Paste Until Last Row

Unexpc

Active Member
Joined
Nov 12, 2020
Messages
496
Office Version
  1. 2019
Platform
  1. Windows
Hi guys
i have a page in range A41:H74 and i want copy this page and paste until last row of excel sheet. does any vba code to do this?
 
So are you wanting to paste to this sheet, all the way down, or to other sheets?

If on other pages, how many sheets are there, and are we going to be copying to ALL sheets?

If down the sheet, what is the first row we will be pasting to? Is it the next one (row 75), or are you skipping any rows in between?
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
So are you wanting to paste to this sheet, all the way down, or to other sheets?

If on other pages, how many sheets are there, and are we going to be copying to ALL sheets?

If down the sheet, what is the first row we will be pasting to? Is it the next one (row 75), or are you skipping any rows in between?
copy down this sheet and first cell pasting to row 75 and no skipping any rows
and can i duplicate this sheet with this pages? no problem with this... am i right?
 
Upvote 0
Do you really need to copy down to the bottom of the page?
That is over 30,840 loops!

I have written code that will do that, but it bogging down and timing out, do to the number of times it is running.
If there is some other way to determine exactly how far down it needs to go, that might work better.

Here is the code that I came up with:
VBA Code:
Sub MyCopyRange()

    Dim nr As Long

    Application.ScreenUpdating = False

'   Set initial value of next row
    nr = 34
    
'   Copy range
    Do
        Range("A" & nr + 7 & ":H" & nr + 40).Copy Range("A" & nr + 41)
'       Add 34 to next row
        nr = nr + 34
'       Exit if row number exceeds max
        If nr > 1048576 Then Exit Do
    Loop

    Application.ScreenUpdating = True
    
End Sub
Maybe if you let it run long enough, it will finish.
 
Upvote 0
Solution
one question, when i run macro and doing well copy/paste, the size of worksheet increase to 32MB! and i want duplicate 10 or more this sheet that increase a large amount size for worksheet. this maybe cause damage the file or decrease loading worksheet or anything that's not good?
 
Upvote 0
It shouldn't "damage" it, though it could seriously affect your performance in a negative way (your workbook may become really SLOW!).
Quite frankly, Excel is not the best tool to be storing millions of rows of data. A database is much for something like that (i.e. Microsoft Access, SQL, MySQL, etc).
 
Upvote 0
Do you really need to copy down to the bottom of the page?
That is over 30,840 loops!

I have written code that will do that, but it bogging down and timing out, do to the number of times it is running.
If there is some other way to determine exactly how far down it needs to go, that might work better.

Here is the code that I came up with:
VBA Code:
Sub MyCopyRange()

    Dim nr As Long

    Application.ScreenUpdating = False

'   Set initial value of next row
    nr = 34
  
'   Copy range
    Do
        Range("A" & nr + 7 & ":H" & nr + 40).Copy Range("A" & nr + 41)
'       Add 34 to next row
        nr = nr + 34
'       Exit if row number exceeds max
        If nr > 1048576 Then Exit Do
    Loop

    Application.ScreenUpdating = True
  
End Sub
Maybe if you let it run long enough, it will finish.
do you suggestion nr > 1048576 change number to less number than this ?
and another question, pefomance of system effect to fastest this or excel is not strong to do?
 
Upvote 0
do you suggestion nr > 1048576 change number to less number than this ?
If possible, yes. But it really depends on what the needs are, and you haven't clearly explains them.
Note that it doesn't matter if you did 1,000,000 million records on one page, or 100,000 records on ten pages. That uses the same amount of data.

pefomance of system effect to fastest this or excel is not strong to do?
I am not sure what you are asking here (doesn't really seem to be a well-formed sentence).
Basically, Excel is designed to do calculations. However, using it store millions upon million rows of data will have an adverse affect on performance. That is not really what it was designed to do. It was not really intended to store immense amounts of data (at least not if you want to be able to work with the data).
 
Upvote 0
another thing, this i ask you, a print page from my main worksheet and i linked main sheet cells to this print sheet. i want when a page fill, next page automatically insert like insert page but automatically, do you have any idea to do this?
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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