PDA

View Full Version : Create Combined Table from 2 Tables



ShawnMichael
06-11-2014, 10:10 AM
Hi there !

Hope you all fine :) Trying to get my head around but couldn't figure it out :(

Well, I have 2 tables, Table 1 and Table 2, which are updated regularly.

Table 1


Date
Present
Class
Teacher


01/01/2014
1
General Science
John Little



Table 2


Date
Present
Class
Teacher


01/01/2014
2
Political Science
Armanda Smith



After every class, both tables are updated by adding a new row. Now I need a Table 3, which will auto-update and combine the data from both tables like this:

Table 3


Date
Present
Class
Teacher


01/01/2014
1
General Science
John Little


01/01/2014
2
Political Science
Armanda Smith



If we add new row to either table (T1 orT2), rows in T3 will be updated and take the data from those tables and add to the existing data in T3 in the next empty row, either using formulas or VBA.

I hope I have explained it well and I would appreciate your help in this regard.


Regards

ranman256
06-11-2014, 11:27 AM
2 append queries.
append tbl1.* into tbl3
then
append tbl2.* into tbl3

why are you using 2 tables to begin with, and not just use tbl3?

snb
06-11-2014, 01:57 PM
Sub M_snb()
With Sheets("sheet3").ListObjects(1).DataBodyRange
.Delete
Sheets("sheet1").ListObjects(1).DataBodyRange.Copy .Cells(1)
End With
Sheets("sheet2").ListObjects(1).DataBodyRange.Copy Sheets("sheet3").Cells(Sheets("sheet3").ListObjects(1).DataBodyRange.Rows.Count + 2, 1)
End Sub