Macro to copy non contigious visible cells & columns as below from sheet 1 to sheet 2 in column A1
Take note sheet 1 represents collapse subtotals .there all headers from Columns A 1 to ZZ.
So all headers in which there is no data in first cells should be ignored.
Only those headers with its visible data cells up to end should be copied to sheet 2 with their column size .as esample below .
sheet 1
[TABLE="width: 790"]
<colgroup><col><col span="4"><col><col span="2"><col><col></colgroup><tbody>[TR]
[TD]Columns M
[/TD]
[TD]Columns N[/TD]
[TD]Columns O [/TD]
[TD]Columns P [/TD]
[TD]Columns Q[/TD]
[TD]Columns R[/TD]
[TD]Columns S [/TD]
[TD]Columns T [/TD]
[TD]Columns U
[/TD]
[TD]Columns W
[/TD]
[/TR]
[TR]
[TD]PRODUCT
[/TD]
[TD]Qty_1[/TD]
[TD]Litres [/TD]
[TD]Sugar[/TD]
[TD]Qty [/TD]
[TD]QTY[/TD]
[TD]Unit [/TD]
[TD]@[/TD]
[TD]Amount[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]COFFEE[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]1000
[/TD]
[TD="align: right"]23.16
[/TD]
[/TR]
[TR]
[TD]WINES
[/TD]
[TD="align: right"]12
[/TD]
[TD="align: right"]9
[/TD]
[TD="align: right"]0
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]2000
[/TD]
[TD="align: right"]15
[/TD]
[/TR]
[TR]
[TD]CONDIMENTS
[/TD]
[TD="align: right"]0
[/TD]
[TD="align: right"]0
[/TD]
[TD="align: right"]0
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]300
[/TD]
[TD="align: right"]97.2
[/TD]
[/TR]
[TR]
[TD]BRUSHES[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]20
[/TD]
[TD="align: right"]9.72
[/TD]
[/TR]
[TR]
[TD]BISCUITS[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]10
[/TD]
[TD="align: right"]13.68[/TD]
[/TR]
[TR]
[TD]CEREAL[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]22
[/TD]
[TD="align: right"]74.4
[/TD]
[/TR]
[TR]
[TD]CHOCOLATE[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]20
[/TD]
[TD="align: right"]5.76
[/TD]
[/TR]
</tbody>[/TABLE]
SHEET 2
EXPECTED RESULTS
[TABLE="width: 480"]
<colgroup><col><col span="4"><col></colgroup><tbody>[TR]
[TD]Columns A
[/TD]
[TD]Columns B[/TD]
[TD]Columns C [/TD]
[TD]Columns D [/TD]
[TD]Columns E[/TD]
[TD]Columns F [/TD]
[/TR]
[TR]
[TD]PRODUCT[/TD]
[TD]Qty_1[/TD]
[TD]Litres [/TD]
[TD]Sugar[/TD]
[TD]Amount[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]COFFEE[/TD]
[TD="align: right"]0
[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1000[/TD]
[TD="align: right"]23.16
[/TD]
[/TR]
[TR]
[TD]WINES[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]2000[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD]CONDIMENTS[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]300[/TD]
[TD="align: right"]97.2
[/TD]
[/TR]
[TR]
[TD]BRUSHES[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]9.72[/TD]
[/TR]
[TR]
[TD]BISCUITS[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]13.68[/TD]
[/TR]
[TR]
[TD]CEREAL[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]74.4[/TD]
[/TR]
[TR]
[TD]CHOCOLATE[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]5.76[/TD]
[/TR]
</tbody>[/TABLE]
Take note sheet 1 represents collapse subtotals .there all headers from Columns A 1 to ZZ.
So all headers in which there is no data in first cells should be ignored.
Only those headers with its visible data cells up to end should be copied to sheet 2 with their column size .as esample below .
sheet 1
[TABLE="width: 790"]
<colgroup><col><col span="4"><col><col span="2"><col><col></colgroup><tbody>[TR]
[TD]Columns M
[/TD]
[TD]Columns N[/TD]
[TD]Columns O [/TD]
[TD]Columns P [/TD]
[TD]Columns Q[/TD]
[TD]Columns R[/TD]
[TD]Columns S [/TD]
[TD]Columns T [/TD]
[TD]Columns U
[/TD]
[TD]Columns W
[/TD]
[/TR]
[TR]
[TD]PRODUCT
[/TD]
[TD]Qty_1[/TD]
[TD]Litres [/TD]
[TD]Sugar[/TD]
[TD]Qty [/TD]
[TD]QTY[/TD]
[TD]Unit [/TD]
[TD]@[/TD]
[TD]Amount[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]COFFEE[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]1000
[/TD]
[TD="align: right"]23.16
[/TD]
[/TR]
[TR]
[TD]WINES
[/TD]
[TD="align: right"]12
[/TD]
[TD="align: right"]9
[/TD]
[TD="align: right"]0
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]2000
[/TD]
[TD="align: right"]15
[/TD]
[/TR]
[TR]
[TD]CONDIMENTS
[/TD]
[TD="align: right"]0
[/TD]
[TD="align: right"]0
[/TD]
[TD="align: right"]0
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]300
[/TD]
[TD="align: right"]97.2
[/TD]
[/TR]
[TR]
[TD]BRUSHES[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]20
[/TD]
[TD="align: right"]9.72
[/TD]
[/TR]
[TR]
[TD]BISCUITS[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]10
[/TD]
[TD="align: right"]13.68[/TD]
[/TR]
[TR]
[TD]CEREAL[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]22
[/TD]
[TD="align: right"]74.4
[/TD]
[/TR]
[TR]
[TD]CHOCOLATE[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]20
[/TD]
[TD="align: right"]5.76
[/TD]
[/TR]
</tbody>[/TABLE]
SHEET 2
EXPECTED RESULTS
[TABLE="width: 480"]
<colgroup><col><col span="4"><col></colgroup><tbody>[TR]
[TD]Columns A
[/TD]
[TD]Columns B[/TD]
[TD]Columns C [/TD]
[TD]Columns D [/TD]
[TD]Columns E[/TD]
[TD]Columns F [/TD]
[/TR]
[TR]
[TD]PRODUCT[/TD]
[TD]Qty_1[/TD]
[TD]Litres [/TD]
[TD]Sugar[/TD]
[TD]Amount[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]COFFEE[/TD]
[TD="align: right"]0
[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1000[/TD]
[TD="align: right"]23.16
[/TD]
[/TR]
[TR]
[TD]WINES[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]2000[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD]CONDIMENTS[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]300[/TD]
[TD="align: right"]97.2
[/TD]
[/TR]
[TR]
[TD]BRUSHES[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]9.72[/TD]
[/TR]
[TR]
[TD]BISCUITS[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]13.68[/TD]
[/TR]
[TR]
[TD]CEREAL[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]74.4[/TD]
[/TR]
[TR]
[TD]CHOCOLATE[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]5.76[/TD]
[/TR]
</tbody>[/TABLE]