Forum Discussion
Malcolm McMaster
Jun 02, 2017Copper Contributor
Macro to copy data to another sheet
Hi All, I have a worksheet that serves as a data entry form & another worksheet that stores historic data. I would like to be able to enter the new data in the data entry form & then by macro, p...
Smitty Smith
Jun 05, 2017Former Employee
See if this gets you started:
Sub foo()
Dim lr As Long
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Set wsSource = Sheets("Input")
Set wsDest = Sheets("Data")
lr = wsDest.Cells(Rows.Count, "A").End(xlUp).Row + 1
wsDest.Range("A" & lr).Value = wsSource.Range("A1").Value
wsDest.Range("B" & lr).Value = wsSource.Range("B1").Value
wsDest.Range("C" & lr).Value = wsSource.Range("C1").Value
wsDest.Range("D" & lr).Value = wsSource.Range("D1").Value
End Sub
It copies A1:D1 from one sheet to the next empty row in another sheet. You'll need to adjust your input ranges to suit. The lr method is what sets the next empty row.
HTH