Copy data to second sheet appending at top with date

alex0182828

Board Regular
Joined
Jun 20, 2012
Messages
87
Office Version
  1. 365
Platform
  1. MacOS
Hi All,

Can anyone help me copy data from one tab to another using macro. The data should be copied to the second log tab and then appended to the top of the list and the date the macro is run inserted. The exisiting data in the log tab is pushed down to the bottom and anothing is deleted. Im using office 365 mac if that makes a difference.

Mr Excel Example.xlsx
ABCDE
1Header 1Header 2 Header 3Header 4
2This data needs copiedThis data needs copiedThis data needs copied
3This data needs copiedThis data needs copiedThis data needs copied
4This data needs copiedThis data needs copiedThis data needs copied
5This data needs copiedThis data needs copiedThis data needs copied
6This data needs copiedThis data needs copiedThis data needs copied
7This data needs copiedThis data needs copiedThis data needs copied
8This data needs copiedThis data needs copiedThis data needs copied
9This data needs copiedThis data needs copiedThis data needs copied
Copy From


Mr Excel Example.xlsx
ABCDE
1DateHeader 1Header 2 Header 3Header 4
2Date is inserted by macroCopied DataCopied DataCopied Data
3Date is inserted by macroCopied DataCopied DataCopied Data
4Date is inserted by macroCopied DataCopied DataCopied Data
5Date is inserted by macroCopied DataCopied DataCopied Data
6Date is inserted by macroCopied DataCopied DataCopied Data
7Date is inserted by macroCopied DataCopied DataCopied Data
8Date is inserted by macroCopied DataCopied DataCopied Data
9Date is inserted by macroCopied DataCopied DataCopied Data
10Old DataOld DataOld DataOld Data
11Old DataOld DataOld DataOld Data
12Old DataOld DataOld DataOld Data
13Old DataOld DataOld DataOld Data
14Old DataOld DataOld DataOld Data
15Old DataOld DataOld DataOld Data
16Old DataOld DataOld DataOld Data
17Old DataOld DataOld DataOld Data
18Old DataOld DataOld DataOld Data
19Old DataOld DataOld DataOld Data
20Old DataOld DataOld DataOld Data
21Old DataOld DataOld DataOld Data
22Old DataOld DataOld DataOld Data
23Old DataOld DataOld DataOld Data
24Old DataOld DataOld DataOld Data
Log
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try:
VBA Code:
Sub alex()
Dim lastrow As Long
lastrow = Sheets("Copy From").Range("A" & Rows.Count).End(xlUp).Row

With Sheets("Log")
    .Rows("2:" & lastrow).Insert Shift:=xlShiftDown
    .Range("B2:E" & lastrow).Value = Sheets("Copy From").Range("A2:D" & lastrow).Value
    .Range("A2:A" & lastrow).Value = Date
End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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