I have a worksheet that has been sparsely populated with data that needs to go into several relational database tables. The sheet looks like this:
A B C D E F G
Table_1 Table_2 Table_2 Table_3 Table_3 Table_3 Table_3
Table_3 Table_3 Table_3 Table_3
Table_2 Table_2 Table_3 Table_3 Table_3 Table_3
Table_3 Table_3 Table_3 Table_3
Table_2 Table_2 Table_3 Table_3 Table_3 Table_3
Table_3 Table_3 Table_3 Table_3
Table_1 Table_2 Table_2 Table_3 Table_3 Table_3 Table_3
Table_3 Table_3 Table_3 Table_3
Table_2 Table_2 Table_3 Table_3 Table_3 Table_3
Table_3 Table_3 Table_3 Table_3
Table_2 Table_2 Table_3 Table_3 Table_3 Table_3
Table_3 Table_3 Table_3 Table_3
Given this data, I would generate SQL that would populate data in column A in Table_1
, columns B and C in Table_2
(with a foreign key reference to the value from Table_1
) and columns D, E and F in Table_3
(with a foreign key reference to the value from Table_2
). The SQL can be placed in a separate sheet, a text file, the clipboard--pretty much anywhere.
I can manipulate the table if necessary (to fill in values, re-arrange data, whatever) but would prefer to avoid this manual step. What I'm hoping is that there's some Excel/VBA macro where I can pass the source range (or sheet), and then the sub ranges for each table, and have the macro know how to find the reference back to the parent table.