rorobear
01-10-2023, 10:04 AM
Hello Everyone,
If someone could assist with this little macro I’d really appreciate it. I have a workbook with to sheets, InvoiceSheet and DataSheet. My code, when the ADD TO RECORD button is clicked, copys the very last row on the InvoiceSheet to the next empty row in the DataSheet, but that’s not what I want. I want to copy the last in the InvoiceSheet starting from row B18. I’ve attached the Workbook. Any assistance is greatly appreciated.
Option Explicit
Sub RecordofInvoice()
Dim lastrowSrc As Long
Dim lastrowDest As Long
'Get last row of data
lastrowSrc = Sheets("InvoiceSheet").Range("B" & Rows.Count).End(xlUp).Row
'Get first blank row (last row of data +1)
lastrowDest = Sheets("DataSheet").Range("B" & Rows.Count).End(xlUp).Row + 1
'Copy row
Sheets("InvoiceSheet").Range("B" & lastrowSrc).EntireRow.Copy Sheets("DataSheet").Range("A" & lastrowDest)
End Sub
If someone could assist with this little macro I’d really appreciate it. I have a workbook with to sheets, InvoiceSheet and DataSheet. My code, when the ADD TO RECORD button is clicked, copys the very last row on the InvoiceSheet to the next empty row in the DataSheet, but that’s not what I want. I want to copy the last in the InvoiceSheet starting from row B18. I’ve attached the Workbook. Any assistance is greatly appreciated.
Option Explicit
Sub RecordofInvoice()
Dim lastrowSrc As Long
Dim lastrowDest As Long
'Get last row of data
lastrowSrc = Sheets("InvoiceSheet").Range("B" & Rows.Count).End(xlUp).Row
'Get first blank row (last row of data +1)
lastrowDest = Sheets("DataSheet").Range("B" & Rows.Count).End(xlUp).Row + 1
'Copy row
Sheets("InvoiceSheet").Range("B" & lastrowSrc).EntireRow.Copy Sheets("DataSheet").Range("A" & lastrowDest)
End Sub