I have created the following VBA for user to copy data from Sheet "fromtext" to sheet"report" which contain a table that I created (the table is created with ctrl + T , not ordinary range table.
There will always be time users will need to duplicate the workbook to compile data for a brand new year.
So for this, after a new duplicated workbook is created, they will clear the content in the table and start run the VBA again.
But the problem is, everytime after the table cleared, the data always pasted at the last row of table which automatically make the data cannot fit into the table nicely.
So , I thinking of modify my current code, but I need advice.
There will always be time users will need to duplicate the workbook to compile data for a brand new year.
So for this, after a new duplicated workbook is created, they will clear the content in the table and start run the VBA again.
But the problem is, everytime after the table cleared, the data always pasted at the last row of table which automatically make the data cannot fit into the table nicely.
So , I thinking of modify my current code, but I need advice.
Book3.xlsx | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | |||
1 | Order ID | Ship Date | Order Date | Ship Mode | Customer ID | Customer Name | Destination | Contact Number | Status | Segment | ||
2 | ||||||||||||
3 | CA-2014-105893 | 11/18/2014 | 11/11/2014 | Standard Class | PK-19075 | Pete Kriz | New York | 123456 | On the Way | Consumer | ||
4 | CA-2014-167164 | 5/15/2014 | 5/13/2014 | Second Class | AG-10270 | Alejandro Grove | Washington | 123456 | Failed | Consumer | ||
5 | CA-2014-143336 | 9/1/2014 | 8/27/2014 | Second Class | ZD-21925 | Zuschuss Donatelli | New Zealand | 123456 | Delivered | Consumer | ||
6 | CA-2014-143336 | 9/1/2014 | 8/27/2014 | Second Class | ZD-21925 | Zuschuss Donatelli | New York | 123456 | On the Way | Consumer | ||
7 | CA-2014-143336 | 9/1/2014 | 8/27/2014 | Second Class | ZD-21925 | Zuschuss Donatelli | Washington | 123456 | Delivered | Consumer | ||
8 | CA-2016-137330 | 12/13/2016 | 12/9/2016 | Standard Class | KB-16585 | Ken Black | Japan | 123456 | On the Way | Corporate | ||
9 | CA-2016-137330 | 12/13/2016 | 12/9/2016 | Standard Class | KB-16585 | Ken Black | New York | 123456 | Delivered | Corporate | ||
10 | US-2017-156909 | 7/18/2017 | 7/16/2017 | Second Class | SF-20065 | Sandra Flanagan | Washington | 123456 | On the Way | Consumer | ||
11 | CA-2015-106320 | 9/30/2015 | 9/25/2015 | Standard Class | EB-13870 | Emily Burns | New Zealand | 123456 | On the Way | Consumer | ||
12 | CA-2016-121755 | 1/20/2016 | 1/16/2016 | Second Class | EH-13945 | Eric Hoffmann | New York | 123456 | Failed | Consumer | ||
13 | CA-2016-121755 | 1/20/2016 | 1/16/2016 | Second Class | EH-13945 | Eric Hoffmann | Washington | 123456 | On the Way | Consumer | ||
14 | US-2015-150630 | 9/21/2015 | 9/17/2015 | Standard Class | TB-21520 | Tracy Blumstein | New Zealand | 123456 | Delivered | Consumer | ||
15 | US-2015-150630 | 9/21/2015 | 9/17/2015 | Standard Class | TB-21520 | Tracy Blumstein | New York | 123456 | On the Way | Consumer | ||
16 | US-2015-150630 | 9/21/2015 | 9/17/2015 | Standard Class | TB-21520 | Tracy Blumstein | Washington | 123456 | Delivered | Consumer | ||
Sheet1 |
VBA Code:
With Sheets ("fromtext")
. range("A9",.range("A9").end(xlDown).End(xltoright).copy
end with
With sheets("report").listobjects(1).range
.cells(.rows.count+1,1).pastespecial xlvalues
end with
application.cutcopymode=false