Hi all, I need help with a VBA Code. I have an excel table that looks like this:
[TABLE="class: cms_table, width: 1170"]
<tbody>[TR]
[TD="align: right"][/TD]
[TD][/TD]
[TD][TABLE="class: cms_table_grid, width: 500, align: left"]
<tbody>[TR]
[TD]PO[/TD]
[TD]Status[/TD]
[TD]Description[/TD]
[TD]Vendor[/TD]
[TD]Department[/TD]
[TD]Date Approved[/TD]
[TD]Project ID[/TD]
[TD]Before Tax[/TD]
[TD]Tax[/TD]
[TD]After Tax[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[/TR]
[TR]
[TD]100012[/TD]
[TD]Closed[/TD]
[TD]Replenish Motors 1935.70[/TD]
[TD]AIT[/TD]
[TD]750[/TD]
[TD]2017-06-06T07:00:55[/TD]
[TD]2
[/TD]
[TD]30[/TD]
[TD]5[/TD]
[TD]35[/TD]
[TD]2000123[/TD]
[TD]7/23/2018[/TD]
[TD]65[/TD]
[/TR]
[TR]
[TD]100012[/TD]
[TD]Closed[/TD]
[TD]Replenish Motors 1935.70[/TD]
[TD]AIT[/TD]
[TD]752[/TD]
[TD]2017-06-06T07:00:55[/TD]
[TD]2[/TD]
[TD]20[/TD]
[TD]4[/TD]
[TD]24[/TD]
[TD]2000123[/TD]
[TD]7/23/2018[/TD]
[TD]65[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
</tbody>[/TABLE]
I want to consolidate any of the rows that have the same PO numbers and make it look like the table below:
Basically, I want all the columns except for the Before Tax, Tax, and After Tax columns to be consolidated into one value. If the cell values in any of those columns don't match, I would like those values to both be represented in the corresponding combined cell, and separated by a comma (this is demonstrated in the Department column below). For the Before Tax, Tax, and After Tax columns, I would like the values to be added up and the row to just show the grand total. If someone could please help to formulate a VBA code that can do this that would be a huge help. Thank you!
[TABLE="class: cms_table_grid, width: 500, align: left"]
<tbody>[TR]
[TD]PO[/TD]
[TD]Status[/TD]
[TD]Description[/TD]
[TD]Vendor[/TD]
[TD]Department[/TD]
[TD]Date Approved[/TD]
[TD]Project ID[/TD]
[TD]Before Tax[/TD]
[TD]Tax[/TD]
[TD]After Tax[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[/TR]
[TR]
[TD]100012[/TD]
[TD]Closed[/TD]
[TD]Replenish Motors 1935.70[/TD]
[TD]AIT[/TD]
[TD]750, 752[/TD]
[TD]2017-06-06T07:00:55[/TD]
[TD]2[/TD]
[TD]50[/TD]
[TD]9[/TD]
[TD]59[/TD]
[TD]2000123[/TD]
[TD]7/23/2018[/TD]
[TD]65
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: cms_table, width: 1170"]
<tbody>[TR]
[TD="align: right"][/TD]
[TD][/TD]
[TD][TABLE="class: cms_table_grid, width: 500, align: left"]
<tbody>[TR]
[TD]PO[/TD]
[TD]Status[/TD]
[TD]Description[/TD]
[TD]Vendor[/TD]
[TD]Department[/TD]
[TD]Date Approved[/TD]
[TD]Project ID[/TD]
[TD]Before Tax[/TD]
[TD]Tax[/TD]
[TD]After Tax[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[/TR]
[TR]
[TD]100012[/TD]
[TD]Closed[/TD]
[TD]Replenish Motors 1935.70[/TD]
[TD]AIT[/TD]
[TD]750[/TD]
[TD]2017-06-06T07:00:55[/TD]
[TD]2
[/TD]
[TD]30[/TD]
[TD]5[/TD]
[TD]35[/TD]
[TD]2000123[/TD]
[TD]7/23/2018[/TD]
[TD]65[/TD]
[/TR]
[TR]
[TD]100012[/TD]
[TD]Closed[/TD]
[TD]Replenish Motors 1935.70[/TD]
[TD]AIT[/TD]
[TD]752[/TD]
[TD]2017-06-06T07:00:55[/TD]
[TD]2[/TD]
[TD]20[/TD]
[TD]4[/TD]
[TD]24[/TD]
[TD]2000123[/TD]
[TD]7/23/2018[/TD]
[TD]65[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
</tbody>[/TABLE]
I want to consolidate any of the rows that have the same PO numbers and make it look like the table below:
Basically, I want all the columns except for the Before Tax, Tax, and After Tax columns to be consolidated into one value. If the cell values in any of those columns don't match, I would like those values to both be represented in the corresponding combined cell, and separated by a comma (this is demonstrated in the Department column below). For the Before Tax, Tax, and After Tax columns, I would like the values to be added up and the row to just show the grand total. If someone could please help to formulate a VBA code that can do this that would be a huge help. Thank you!
[TABLE="class: cms_table_grid, width: 500, align: left"]
<tbody>[TR]
[TD]PO[/TD]
[TD]Status[/TD]
[TD]Description[/TD]
[TD]Vendor[/TD]
[TD]Department[/TD]
[TD]Date Approved[/TD]
[TD]Project ID[/TD]
[TD]Before Tax[/TD]
[TD]Tax[/TD]
[TD]After Tax[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[/TR]
[TR]
[TD]100012[/TD]
[TD]Closed[/TD]
[TD]Replenish Motors 1935.70[/TD]
[TD]AIT[/TD]
[TD]750, 752[/TD]
[TD]2017-06-06T07:00:55[/TD]
[TD]2[/TD]
[TD]50[/TD]
[TD]9[/TD]
[TD]59[/TD]
[TD]2000123[/TD]
[TD]7/23/2018[/TD]
[TD]65
[/TD]
[/TR]
</tbody>[/TABLE]