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?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
For rows with data, is column A always populated?
If so, you can try:
VBA Code:
    Dim lr as Long
'   Find last row in column A with data
    lr = Cells(Rows.Count,"A").End(xlUp).Row
'   Copy range
    Range("A41:H" & lr).Copy
    ...

If row 40 is blank, there are no totally blank rows in the middle of your data, and the data does not go out past column H, you may be able to use Current Region, i.e.
VBA Code:
    Range("A41").CurrentRegion.Copy
    ...
 
Upvote 0
i want paste unitl last row in excel, which line of code?
 
Upvote 0
command error for xlup...
Did you copy/paste or try typing it in?
A common error that people make is to type the number "1" instead of a lower case "l" in "xlUp".
 
Upvote 0
Are you doing in Excel or Google Sheets?
What is the exact error message?
Please post your current code, exactly as you have it.
 
Upvote 0
VBA Code:
Sub CopyPaste()
        Dim lr As Long
        '   Copy range
    Range("A41:H74" & lr).Copy
'   Find last row in column A with data
    lr = Cells(Rows.Count, "A").End(xlUp).Row


    End Sub

no problem for error command(not show xlUp error again), but not paste it, which line of code for paste until last row?
 
Upvote 0
Why did you flip the order of the lines of code I gave you?
You are trying to use the "lr" variable in the copy command before you calculate it/
You must calculate "lr" first before you can use it!

I also left it to you to enter where you want to copy it to (you did not mention where this should be copied).
So you still need the paste postion of the code. If you need help writing that, you need to tell us how to determine where to paste this to.
 
Upvote 0
i have a page from row 41:41 to 74:74 with specific format and data
in my row height , each page have 34 row and i have 8 column that fitted like my page in A41:H74
i want copy from this page and pasted in each page until rows excel is ended (row 1048576)
 
Upvote 0

Forum statistics

Threads
1,213,556
Messages
6,114,284
Members
448,562
Latest member
Flashbond

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