Archive macro

SoupVictim

New Member
Joined
Nov 19, 2013
Messages
8
Hi all,

I have been looking around but i cannot quite find something that fits what i need. Let me explain.

I need to copy all rows and data from a table (table1) in a worksheet and paste them at the end of another table (table2) in another worksheet in the same workbook. But i would like the rows and data that are pasted into (table2) to have the first column in each row auto filled with todays date. As you can see i hope to create an archive type table of data. After pasting the data into (table2) i require columns 2 and 3 in (table1) to be emptied.

I hope that all makes sense and is not to tricky.

Any help is most appreciated.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Can you provide:

* Sheetname from
* Sheetname to
* Range of data sheetname from
* Are there headers included in that range?
 
Upvote 0
Sheetname from = worksheet1
Sheetname to = worksheet2
range of data = can this be the name of the table to encompass all data in a dynamic table? (may have more rows sometimes) if so then its table1.
headers = no headers, both tables have the same columns except table2 will have an extra first column which will be auto filled with todays date.
 
Last edited:
Upvote 0
Code:
Sub archive()
Dim LastArchive As Integer
LastArchive = ThisWorkbook.Sheets("Worksheet2").Cells(1, 1).End(xlDown).Row
 If LastArchive = 2 Then LastArchive = 1
 
 ThisWorkbook.Sheets("worksheet1").Range("Table1").Copy _
 Destination:=Sheets("Worksheet2").Range("A" & LastArchive + 1).Offset(0, 1)
 
Dim LastNewEntry As Integer
LastNewEntry = ThisWorkbook.Sheets("Worksheet2").Cells(1, 2).End(xlDown).Row


 ThisWorkbook.Sheets("worksheet2").Range("A" & LastArchive + 1 & ":A" & LastNewEntry).Value = Date


ThisWorkbook.Sheets("Worksheet1").Range("Table1").ClearContents




End Sub

Maybe this will be sufficient to your needs.
 
Upvote 0

Forum statistics

Threads
1,215,330
Messages
6,124,305
Members
449,150
Latest member
NyDarR

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