Paste in range of data to match with another column length - VBA

Apple08

Active Member
Joined
Nov 1, 2014
Messages
449
Hi

I have to paste in the last row data of Columns A & B up to the last row of column L. For example if the last row data of columns A&B are A18 & B18, and the last row data of column L is L30, then I need to paste in A18 data up to A30, B18 data up to B30 to match up with the last row of L.

Please could anyone help to tell me a dynamic way to do that. Many thanks.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Dim c As Range, rng
Dim lastRow1 As Long
Dim lastRow2 As Long
lastRow1 = Cells(Rows.Count, "l").End(xlUp).Row
lastRow2 = Cells(Rows.Count, "a").End(xlUp).Row
Range("A" & lastRow2 & ":A" & lastRow1).FillDown
lastRow2 = Cells(Rows.Count, "b").End(xlUp).Row
Range("b" & lastRow2 & ":b" & lastRow1).FillDown
 
Upvote 0
Thanks very much! It works perfectly! Please I would like to ask about the meaning of Dim c As Range, rng. I understand Dim c as Range but unsure about rng. Also it looks like c hasn't been used within the VBA?
 
Upvote 0

Forum statistics

Threads
1,203,241
Messages
6,054,322
Members
444,717
Latest member
melindanegron

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