Here is an example to help you understand instance referencing.
--------------------------------------------------------------------------------------
In my example i have a
- duplicate button - to duplicate the table
- a numeric field to keep track of the instances
- a table with single repeating row and an add row button
- I also have another table (hidden) with repeating row and add row button (not really needed)

Add Row Button - click event javascript
//add a row to table1
this.resolveNode('Table1._Row1').addInstance(1);
if (xfa.host.version < 😎 {
xfa.form.recalculate(1);
}
//with each click show the current instance in NumericField1
NumericField1.rawValue = Table1.Row1.instanceManager.count;
For the purposes of testing,
i added initialize code to the textfield in the table
this.rawValue = Table1.Row1.instanceManager.count; //when a new row is created, so is a textfield and it gets the value of the instance.
Duplicate Button - click event javascript
//show table2
//logic to determine the amount of instances (rows)
//logic to duplicate textfield contents into table2.
switch(NumericField1.rawValue)
{
case 2: //if NumericField1's value is 2, execute this code
Table2.presence = "visible"; //show the hidden table
this.resolveNode('Table2._Row1').addInstance(1); //add one row only because the table starts with 1 row initially
this.resolveNode("Table2.Row1[0].TextField1").rawValue = this.resolveNode("Table1.Row1[0].TextField1").rawValue; //give the textfield in table2 the same as the value in table1. Row1 is instance 0 - [0]
this.resolveNode("Table2.Row1[1].TextField1").rawValue = this.resolveNode("Table1.Row1[1].TextField1").rawValue; //give the textfield in table2 the same as the value in table1. Row2 is instance 1 - [1]
break;
case 3: //if NumericField1's value is 3, execute this code
Table2.presence = "visible"; //show the hidden table
this.resolveNode('Table2._Row1').addInstance(1);
this.resolveNode('Table2._Row1').addInstance(1);
this.resolveNode("Table2.Row1[0].TextField1").rawValue = this.resolveNode("Table1.Row1[0].TextField1").rawValue; //give the textfield in table2 the same as the value in table1. Row1 is instance 0 - [0]
this.resolveNode("Table2.Row1[1].TextField1").rawValue = this.resolveNode("Table1.Row1[1].TextField1").rawValue; //give the textfield in table2 the same as the value in table1. Row2 is instance 1 - [1]
this.resolveNode("Table2.Row1[2].TextField1").rawValue = this.resolveNode("Table1.Row1[2].TextField1").rawValue; //give the textfield in table2 the same as the value in table1. Row3 is instance 2 - [2]
break;
case 4: //if NumericField1's value is 4, execute this code
Table2.presence = "visible"; //show the hidden table
this.resolveNode('Table2._Row1').addInstance(1);
this.resolveNode('Table2._Row1').addInstance(1);
this.resolveNode('Table2._Row1').addInstance(1);
this.resolveNode("Table2.Row1[0].TextField1").rawValue = this.resolveNode("Table1.Row1[0].TextField1").rawValue; //give the textfield in table2 the same as the value in table1. Row1 is instance 0 - [0]
this.resolveNode("Table2.Row1[1].TextField1").rawValue = this.resolveNode("Table1.Row1[1].TextField1").rawValue; //give the textfield in table2 the same as the value in table1. Row2 is instance 1 - [1]
this.resolveNode("Table2.Row1[2].TextField1").rawValue = this.resolveNode("Table1.Row1[2].TextField1").rawValue; //give the textfield in table2 the same as the value in table1. Row3 is instance 2 - [2]
this.resolveNode("Table2.Row1[3].TextField1").rawValue = this.resolveNode("Table1.Row1[3].TextField1").rawValue; //give the textfield in table2 the same as the value in table1. Row4 is instance 3 - [3]
break;
default: //if NumericField1's value is not any of the previously specified cases, execute this code
//enter code to execute if the logic above is not matched.
break;
}
Notes:
- In this example, a value of 0 or 5 or more in NumericField1 will make the switch refer to the default code to be executed, which in this case is nothing.
Clicking Duplicate does nothing as the Instance Count numeric field does not meet the switch logic.

I added 3 rows in table1, then clicked Duplicate. Table2 is shown, two more rows are added, text from table1 is duplicated to the correct rows in table2.

This is by no means bulletproof code, there probably are other logic considerations, but it should give you a good start with referencing instances.