Copy Paste Last Row VBA

Lauren123

New Member
Joined
Mar 16, 2018
Messages
28
Hi I have this macro where it selects a range tehn copy and paste it on another sheet, but I would like to do it on the last row, is that possible?

Sub CopiaDetalle()


Ultimafila = Worksheets("U-Detail").Range("C" & Rows.Count).End(xlUp).Row
UltimafilaD = Worksheets("Detail").Range("C" & Rows.Count).End(xlUp).Row


Set rng = Workbooks(Wk_Name).Worksheets("U-Detail").Range("C11:AC" & Ultimafila)
rng.Copy
Workbooks(Wk_Name).Worksheets("Detail").Range(UltimafilaD).PasteSpecial xlPasteValues


End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Check the code below code, take care of the changes marked with red font and ammend it to suit your needs.

Code:
Sub CopiaDetalle()[B][COLOR=#ff0000]    Wk_Name = ThisWorkbook.Name[/COLOR][/B]
    Ultimafila = Worksheets("U-Detail").Range("C" & Rows.Count).End(xlUp).Row
    UltimafilaD = Worksheets("Detail").Range("C" & Rows.Count).End(xlUp).Row
    
    Set Rng = Workbooks(Wk_Name).Worksheets("U-Detail").Range("C11:AC" & Ultimafila)
    Rng.Copy
    Workbooks(Wk_Name).Worksheets("Detail").Range([B][COLOR=#ff0000]"C" &[/COLOR][/B] UltimafilaD).PasteSpecial xlPasteValues
End Sub
 
Upvote 0
BTW;

Code:
[B][COLOR=#ff0000]Wk_Name = ThisWorkbook.Name[/COLOR][/B]

should be the second line. May be this fault is because of the browser i am using (Chrome)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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