Consolidating data with same headers from multiple worksheets into master worksheet

moonstex

New Member
Joined
Jun 18, 2015
Messages
11
Hi Guys,

PLease help me out. I need a VBA code or any other solution to produce the following.

Basically, I have two datasets where the same information is stored for different countries, and I need to merge them into one quite often.


Dataset 1 example


[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Country[/TD]
[TD]Type[/TD]
[TD]Sub-type[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]USA[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Canada[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Sweden[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Norway[/TD]
[TD]fruit[/TD]
[TD]Pear[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]

For every row where there is no data there is a 0

Dataset 2 example

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Country[/TD]
[TD]Type[/TD]
[TD]Sub-type[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Azerbaijan[/TD]
[TD]Vegetable[/TD]
[TD]Cucumber[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]India[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Thailand[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Bangladesh[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Exactly same headers and same data but for different set of countries


Consolidated Dataset (this is what I'm trying to automate)

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Country[/TD]
[TD]Type[/TD]
[TD]Sub-Type[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]USA[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Canada[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Sweden[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Norway[/TD]
[TD]Fruit[/TD]
[TD]Pear[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Azerbaijan[/TD]
[TD]Vegetable[/TD]
[TD]Cucumber[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]India[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Thailand[/TD]
[TD]VEgetable[/TD]
[TD]Tomato[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Bangladesh[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]

Basically, I want to copy paste all data from 2 datasets, right after each other without taking into account 0's. Zeros are basically blanks


Please help!

Thanks. S
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
This is just an example. In reality, both datasets have about 2000 rows and 150 columns and are updated daily. At the same times there are satellite tools that produce analysis based on the data in both. Before they were all in the same files, but due to multiple people working on the data, we decided to split based on countries. Now every time we need to run analysis from satelite tools, we have to copy paste. Would be amazing to make it more efficient somehow. Macro, or some kind of combines Pivot Tables, automatically refreshable sheet i don't know...
 
Upvote 0
[TABLE="width: 896"]
<colgroup><col width="64" span="14" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]Country[/TD]
[TD="width: 64"]Type[/TD]
[TD="width: 64"]Sub-type[/TD]
[TD="width: 64"]Amount[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"]Country[/TD]
[TD="width: 64"]Type[/TD]
[TD="width: 64"]Sub-type[/TD]
[TD="width: 64"]Amount[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[/TR]
[TR]
[TD]USA[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Azerbaijan[/TD]
[TD]Vegetable[/TD]
[TD]Cucumber[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Canada[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]India[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sweden[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Thailand[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Norway[/TD]
[TD]fruit[/TD]
[TD]Pear[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Bangladesh[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]0[/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="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 5"]this macro takes the valid rows from the 2 data sets[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"]and merges them[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]rrow = 19[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"] For j = 1 To 100[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 4"] If Cells(j, 1) = 0 Then GoTo 100[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"] rrow = rrow + 1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"] Cells(rrow, 1) = Cells(j, 1)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"] Cells(rrow, 2) = Cells(j, 2)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Country[/TD]
[TD]Type[/TD]
[TD]Sub-type[/TD]
[TD]Amount[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"] Cells(rrow, 3) = Cells(j, 3)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]USA[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"] Cells(rrow, 4) = Cells(j, 4)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Canada[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] Next j[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sweden[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"]100 For j = 2 To 100[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Norway[/TD]
[TD]fruit[/TD]
[TD]Pear[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 4"] If Cells(j, 9) = 0 Then GoTo 200[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Azerbaijan[/TD]
[TD]Vegetable[/TD]
[TD]Cucumber[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"] rrow = rrow + 1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]India[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"] Cells(rrow, 1) = Cells(j, 9)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Thailand[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"] Cells(rrow, 2) = Cells(j, 10)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bangladesh[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"] Cells(rrow, 3) = Cells(j, 11)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"] Cells(rrow, 4) = Cells(j, 12)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] Next j[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"]200 End Sub[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi Guys,

PLease help me out. I need a VBA code or any other solution to produce the following.

Basically, I have two datasets where the same information is stored for different countries, and I need to merge them into one quite often.


Dataset 1 example


[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Country[/TD]
[TD]Type[/TD]
[TD]Sub-type[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]USA[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Canada[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Sweden[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Norway[/TD]
[TD]fruit[/TD]
[TD]Pear[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]

For every row where there is no data there is a 0

Dataset 2 example

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Country[/TD]
[TD]Type[/TD]
[TD]Sub-type[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Azerbaijan[/TD]
[TD]Vegetable[/TD]
[TD]Cucumber[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]India[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Thailand[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Bangladesh[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Exactly same headers and same data but for different set of countries


Consolidated Dataset (this is what I'm trying to automate)

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Country[/TD]
[TD]Type[/TD]
[TD]Sub-Type[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]USA[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Canada[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Sweden[/TD]
[TD]Vegetable[/TD]
[TD]Tomato[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Norway[/TD]
[TD]Fruit[/TD]
[TD]Pear[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Azerbaijan[/TD]
[TD]Vegetable[/TD]
[TD]Cucumber[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]India[/TD]
[TD]Fruit[/TD]
[TD]Orange[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Thailand[/TD]
[TD]VEgetable[/TD]
[TD]Tomato[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Bangladesh[/TD]
[TD]Fruit[/TD]
[TD]Apple[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]

Basically, I want to copy paste all data from 2 datasets, right after each other without taking into account 0's. Zeros are basically blanks


Please help!

Thanks. S
Hi,
For example, Dataset 1 is in Sheet1, Dataset 2 is in Sheet2.
I make a Sheet3 with Form to Consolidate Data
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Country[/TD]
[TD]Type[/TD]
[TD]Sub-type[/TD]
[TD]Amount[/TD]
[/TR]
</tbody>[/TABLE]
VBA code is:
Sub Consolidate_Data()
Dim Ws As Worksheet, I As Long, sR As Long, Rng As Range

For Each Ws In ThisWorkbook.Sheets
If Ws.Name <> "Sheet3" Then
With Ws
I = 2
Do While .Cells(I, 1) > 0
Set Rng = .Cells(I, 1).Resize(, 4)
With Sheet3
sR = .Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & sR).Resize(, 4) = Rng.Value
End With
I = I + 1
Loop
End With
End If
Next Ws
End Sub
 
Upvote 0
Hello,

I also would like to consolidate data. I have 7 companies (agencies) with 3 worksheets each (Worksheet A,B,C). Different agency related info on each worksheet. I would like to consolidate the data from all 7 companies and create one worksheet A, one worksheet B, and one Worksheet C. I have tried using multiple tables to create a pivot table and consolidating worksheets. The results have been less than stellar, but I have no experience with VBA codes. Can you help please?
 
Upvote 0
Hello,

I also would like to consolidate data. I have 7 companies (agencies) with 3 worksheets each (Worksheet A,B,C). Different agency related info on each worksheet. I would like to consolidate the data from all 7 companies and create one worksheet A, one worksheet B, and one Worksheet C. I have tried using multiple tables to create a pivot table and consolidating worksheets. The results have been less than stellar, but I have no experience with VBA codes. Can you help please?
I can solve your problem.
But I need your sample file to write VBA codes.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top