我有两个表:
Table_1 Table_2
A B C A B C
------------- -------------
1| A1| B1| C1| 1| A2| B2| C2|
2| A1| B1| C1| 2| A2| B2| C2|
3| A1| B1| C1| 3| A2| B2| C2|
Run Code Online (Sandbox Code Playgroud)
结果表:
Table_1
A B C
-------------
1| A1| B1| C1|
2| A1| B1| C1|
3| A1| B1| C1|
4| A2| B2| C2|
5| A2| B2| C2|
6| A2| B2| C2|
Run Code Online (Sandbox Code Playgroud)
Table_2是一个临时表(ListObject),它使用数据连接在数据库中查询条目。
Table_1是一个表(ListObject),用作条目的集合列表。之所以将其分开,是因为(1)缩短了Table_2中的查询时间,并且(2)进行了一些程序编辑。
我有VBA代码,可将Table_2复制到Table_1,然后更新Table_2的连接字符串,以不包括日期在Table_1范围内的条目。结果是Table_2仅提取新数据。
我的代码(正确)将数据从Table_2复制到Table_1:
For Each temprow in Table_2.ListRows
Set newRow = table_1.ListRows.Add
tempRow.Range.Copy
newRow.Range.PasteSpecial …Run Code Online (Sandbox Code Playgroud)