Tango_Bravo
New Member
- Joined
- Jun 14, 2017
- Messages
- 33
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I have a few tables in one worksheet. All of them have different names. All start at one row, but at different column. In one of the tables I have a 2dimensional array. Array comprises information about documents (call them 'original'), which have been subsequently amended with another document (call them 'amendment').
here is a sample:
[TABLE="width: 420"]
<tbody>[TR]
[TD]Orig doc
[/TD]
[TD]amendment
[/TD]
[TD]Date
[/TD]
[TD]Column4
[/TD]
[TD]Column5
[/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002540
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002541
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002564
[/TD]
[TD]27.11.2017
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002696
[/TD]
[TD]27.3.2018
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002697
[/TD]
[TD]27.3.2018
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002566
[/TD]
[TD]30.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002593
[/TD]
[TD]21.12.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002594
[/TD]
[TD]21.12.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Col 1 represents indentification of the original document. Col 2 represents identification of the current document. Col. 3 represents date of the current document. Whenever vc(c, 1) = vc(c, 2) we are looking at original document. Whenever vc(c, 1) <> vc(c, 2) we are looking at amendment. Col 1 helps me keep track the original document. Cols 2 and 3 provide the details of the amendment.
I would like, upon each amendment to insert new line containing the details of the original document. here is an example of what I want to achieve (added row are marked up in red):
[TABLE="width: 420"]
<tbody>[TR]
[TD]Orig Invoice
[/TD]
[TD]Secondary doc
[/TD]
[TD]Date
[/TD]
[TD]Column4
[/TD]
[TD]Column5
[/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002540
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002541
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002540
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002564
[/TD]
[TD]27.11.2017
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002696
[/TD]
[TD]27.3.2018
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002564
[/TD]
[TD]27.11.2017
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002697
[/TD]
[TD]27.3.2018
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002564
[/TD]
[TD]27.11.2017
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002566
[/TD]
[TD]30.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002593
[/TD]
[TD]21.12.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002566
[/TD]
[TD]30.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002594
[/TD]
[TD]21.12.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002566
[/TD]
[TD]30.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
this is how far I've reached, and I realise I am doing it totally wrong (it is part of larger code hence).
ReDim vg(1 To UBound(vc, 1), 1 To 10)
For c = 2 To UBound(vc, 1) 'To 2 Step -1
Please help!
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I have a few tables in one worksheet. All of them have different names. All start at one row, but at different column. In one of the tables I have a 2dimensional array. Array comprises information about documents (call them 'original'), which have been subsequently amended with another document (call them 'amendment').
here is a sample:
[TABLE="width: 420"]
<tbody>[TR]
[TD]Orig doc
[/TD]
[TD]amendment
[/TD]
[TD]Date
[/TD]
[TD]Column4
[/TD]
[TD]Column5
[/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002540
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002541
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002564
[/TD]
[TD]27.11.2017
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002696
[/TD]
[TD]27.3.2018
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002697
[/TD]
[TD]27.3.2018
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002566
[/TD]
[TD]30.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002593
[/TD]
[TD]21.12.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002594
[/TD]
[TD]21.12.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Col 1 represents indentification of the original document. Col 2 represents identification of the current document. Col. 3 represents date of the current document. Whenever vc(c, 1) = vc(c, 2) we are looking at original document. Whenever vc(c, 1) <> vc(c, 2) we are looking at amendment. Col 1 helps me keep track the original document. Cols 2 and 3 provide the details of the amendment.
I would like, upon each amendment to insert new line containing the details of the original document. here is an example of what I want to achieve (added row are marked up in red):
[TABLE="width: 420"]
<tbody>[TR]
[TD]Orig Invoice
[/TD]
[TD]Secondary doc
[/TD]
[TD]Date
[/TD]
[TD]Column4
[/TD]
[TD]Column5
[/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002540
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002541
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002540
[/TD]
[TD]VAL00002540
[/TD]
[TD]7.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002564
[/TD]
[TD]27.11.2017
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002696
[/TD]
[TD]27.3.2018
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002564
[/TD]
[TD]27.11.2017
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002697
[/TD]
[TD]27.3.2018
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002564
[/TD]
[TD]VAL00002564
[/TD]
[TD]27.11.2017
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002566
[/TD]
[TD]30.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002593
[/TD]
[TD]21.12.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002566
[/TD]
[TD]30.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002594
[/TD]
[TD]21.12.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]VAL00002566
[/TD]
[TD]VAL00002566
[/TD]
[TD]30.11.2017
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
this is how far I've reached, and I realise I am doing it totally wrong (it is part of larger code hence).
ReDim vg(1 To UBound(vc, 1), 1 To 10)
For c = 2 To UBound(vc, 1) 'To 2 Step -1
g = g + 1
If c = 2 Then
Else
If vc(c, 1) = vc(c - 1, 1) & vc(c, 2) <> vc(c - 1, 2) Then
vg(g, 1).EntireRow.Insert
Else
vg(g, 1) = vc(c, 1)
End If
End if
NextPlease help!