Copy data to the last row and paste below it

vostroxe

New Member
Joined
Jul 13, 2018
Messages
29
Hi guys, i am very new to VBA. I have tried multiple codes from this forum and still can't get it to work. Appreciate if you guys can help me on the scenario.

Scenario Example:
Column N will be determine the last row e.g cell N10.
Copy range will be from A1 until Z10 (based on last row of column N)
Paste to A11
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Not sure I understand. You are looking at N10 though your range goes to Z10? Is this because N10 can be guaranteed to have data in it?
 
Upvote 0
Not sure I understand. You are looking at N10 though your range goes to Z10? Is this because N10 can be guaranteed to have data in it?
Column N guaranteed to have data and will be a determination of the last row of the information. The required information to be copy need to be from A1 to Z10.
 
Upvote 0
Hi & welcome to MrExcel
How about
Code:
Sub CopyData()
   Dim Lr As Long
   Lr = Range("N" & Rows.Count).End(xlUp).Row
   Range("A1:Z" & Lr).Copy Range("A" & Lr + 1)
End Sub
 
Upvote 0
Code:
Dim LastRowNo As Long


Sub CopyDownData()
LastRowNo = Worksheets("Sheet1").Cells(Rows.Count, "N").End(xlUp).Row
 
Range("A1:Z" & LastRowNo).Copy
Range("A" & LastRowNo + 1).PasteSpecial Paste:=xlPasteValues
 
End Sub
 
Upvote 0
@nemmi69
If "Sheet1" is not the active sheet, then your code will be calculate the lastrow on a different sheet from the copy/paste.
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0
Code:
Sub Macro1()

   Dim Lr As Long
   Lr = Range("N" & Rows.Count).End(xlUp).Row
   Range("AA1:AA" & Lr).Formula = "=VLOOKUP(N1,'Sheet1'!A:B,2,0)"
   Range("AA1:AA" & Lr).Copy
   Range("N" & Lr + 1).PasteSpecial xlValues
   Range("AA1:AA" & Lr).ClearContents
   Range("O1:Z" & Lr).Copy Range("O" & Lr + 1)
   Range("A1:M" & Lr).Copy Range("A" & Lr + 1)
   
End Sub
Got further question on this. How do I clear contents on the pasted value area only in case I have amendment on the data. A1 to Z10 to be remain on the Excel.
 
Upvote 0
Would you be looking to clear the contents soon after running the macro, or could it be the next day?
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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