I am trying to copy the last row of sheet 1 which changes everytime, down the amount of rows on sheet2. I have formulas in the last row of sheet1 and would like them carried down.
Below is my code where I select the last row to copy but I cant get it to go down the amount of rows on sheet2.
I need to copy the last row (which a macro puts formulas in) on sheet1. Then I need to copy that last row down the amount of rows on sheet2. Sheet2 data is from A2 to last row of sheet2.
Sheets("2018").Activate
Dim nRow As Long, nColumn As Long
nRow = Cells(Rows.Count, "A").End(xlUp).Row
nColumn = Cells(nRow, Columns.Count).End(xlToLeft).Column
Range(Cells(nRow, "A"), Cells(nRow, nColumn)).Select
Set lastrow = Range(Cells(nRow, "A"), Cells(nRow, nColumn))
bottomrow = Sheets("Needs_Assignment").Cells(Rows.Count, "A").End(xlUp).Row
Range(lastrow).AutoFill Destination:=Range(bottomrow), Type:=xlFillDefault
Thank you
The following worked for me in a recent project (copies formulas in row 1 for columns B to ZZ), so would expect a very similar pattern to work for your scenario:
Dim wrkMyWorkBook As Workbook
'Set wrkMyWorkBook = ' Set this to a valid value
Dim LR As Long
LR = wrkMyWorkBook.Sheets("Target Sheet").Cells(Rows.Count, 1).End(xlUp).Row
wrkMyWorkBook.Sheets("Target Sheet").Range("B1:ZZ1").AutoFill Destination:=wrkMyWorkBook.Sheets("Target Sheet").Range("B1:ZZ" & LR)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.