Merge multiple worksheet columns side by side via VBA

AshAlom

New Member
Joined
Mar 4, 2016
Messages
17
Hi All,

I've searched the forums for this but cant seem to find a solution.
I have multiple worksheets in a workbook, each worksheet has around 7 or 8 columns and the number of rows vary in each workbook. i'm looking for some vba code that will merge the columns next to each other rather than below each other (ive found many codes online that paste below and not side by side).
Column A can remain the same as its has the same data in all sheets but the remaining columns need merging next to each other with a blank column separating them.
Also there are usually around 8 worksheets that need merging.

here's an example:

1st Worksheet
[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[/TR]
</tbody>[/TABLE]

2nd Worksheet
[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="class: grid, width: 600"]
<tbody>[TR]
[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]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD][/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD][/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD][/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[/TR]
[TR]
[TD]Worksheet a[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD]Data 1[/TD]
[TD][/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[TD]Data 2[/TD]
[/TR]
</tbody>[/TABLE]

Hope this makes sense and someone can help.

Thank you.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try this add-in and select "paste data next to each other"
You can also find code here ( you'll have to use LastCol instead of LastRow, see at the bottom)
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
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