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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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