combine two sheets, summing the matching column/row quantities and adding in new any columns and rows that only appear on one of the sheets

Lisa Harris

New Member
Joined
Sep 19, 2016
Messages
17
Hi,

I have been frantically trying different methods and searching for help for a while to complete this, but unable to find a solution that allows you to combine sheets if column headers do not remain constant.

I need a macro that will produce a summary sheet combining an initial despatch log ('Before' tab) with a store orders / back orders log post despatch ('after' tab), so we can quickly view the total amount each one had of each item in the end. However, as time goes on, columns and rows get added in to a master (inserted as well as added to the end) so the 'after' sheet is likely to have additional columns (items) or Rows (stores) to the 'before' sheet and in a different order where new columns have been inserted as a result.

Is there VBA that will combine the two sheets, adding in the new 'unique' columns and rows in the correct order where necessary? then looking up the values and summing?

Any help would be much appreciated - thanks in advance


example of Before sheet:


[TABLE="width: 722"]
<colgroup><col span="4"><col><col span="6"></colgroup><tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]shop no[/TD]
[TD]shop name[/TD]
[TD]type[/TD]
[TD]new format?[/TD]
[TD]limes[/TD]
[TD]apples[/TD]
[TD]bananas[/TD]
[TD]pears[/TD]
[TD]grapes[/TD]
[TD]oranges[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4[/TD]
[TD]store A[/TD]
[TD]type 1[/TD]
[TD]Y[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]2[/TD]
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[TD]type 1[/TD]
[TD]Y[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]


example of After sheet:

[TABLE="width: 931"]
<colgroup><col span="4"><col><col span="6"><col><col span="2"></colgroup><tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[/TR]
[TR]
[TD]1[/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]2[/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]3[/TD]
[TD]shop no[/TD]
[TD]shop name[/TD]
[TD]type[/TD]
[TD]new format?[/TD]
[TD]limes[/TD]
[TD]lemons[/TD]
[TD]apples[/TD]
[TD]bananas[/TD]
[TD]pears1[/TD]
[TD]pears2[/TD]
[TD]TOTAL pears[/TD]
[TD]grapes[/TD]
[TD]oranges[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4[/TD]
[TD]store A[/TD]
[TD]type 1[/TD]
[TD]Y[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]65[/TD]
[TD]Store B[/TD]
[TD]type 2[/TD]
[T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D]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]2[/TD]
[TD]4[/TD]
[TD]1[/TD]
[TD]5[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]32[/TD]
[TD]Store I[/TD]
[TD]type 1[/TD]
[TD]Y[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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