merging files in vba

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I have a file called AllEmployees.xlsx which has one sheet called ALL and inside that sheet an empty table with only labels as below. I have 3 other excel files sales.xlsx, marketing.xlsx and hr.xlsx, each file has one sheet (sales, marketing, hr) and each one has one table as below. I want to write a vba code that move these sheets from sales, marketing and hr files to the AllEmployees files as separate sheets. So the AllEmployees file will have these sheets (ALL, sales,marketing, hr) and then combine all these tables and put them in one table in "All" sheet.


I just watched a video about this but no code was there. https://www.youtube.com/watch?v=Svp9z9PDEIk
I would like to learn how it cam be done. Any help would be appreciated very much. Thanks


AllEmployees.xlsx (sheet All)

[TABLE="width: 500"]
<tbody>[TR]
[TD]name[/TD]
[TD]sex[/TD]
[TD]age[/TD]
[TD]dept[/TD]
[TD]salary[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Sales.xlsx (sheet sales)

[TABLE="width: 500"]
<tbody>[TR]
[TD]name[/TD]
[TD]sex[/TD]
[TD]age[/TD]
[TD]dept[/TD]
[TD]salary[/TD]
[/TR]
[TR]
[TD]john[/TD]
[TD]m[/TD]
[TD]50[/TD]
[TD]sales[/TD]
[TD]20k[/TD]
[/TR]
[TR]
[TD]mary[/TD]
[TD]f[/TD]
[TD]40[/TD]
[TD]sales[/TD]
[TD]40k[/TD]
[/TR]
</tbody>[/TABLE]

marketing.xlsx (sheet marketing)

[TABLE="width: 500"]
<tbody>[TR]
[TD]name[/TD]
[TD]sex[/TD]
[TD]age[/TD]
[TD]dept[/TD]
[TD]salary[/TD]
[/TR]
[TR]
[TD]mike[/TD]
[TD]m[/TD]
[TD]44[/TD]
[TD]marketing[/TD]
[TD]100k[/TD]
[/TR]
[TR]
[TD]anna[/TD]
[TD]f[/TD]
[TD]30[/TD]
[TD]marketing[/TD]
[TD]50k[/TD]
[/TR]
</tbody>[/TABLE]


hr.xlsx (sheet hr)

[TABLE="width: 500"]
<tbody>[TR]
[TD]name[/TD]
[TD]sex[/TD]
[TD]age[/TD]
[TD]dept[/TD]
[TD]salary[/TD]
[/TR]
[TR]
[TD]sara[/TD]
[TD]f[/TD]
[TD]40[/TD]
[TD]hr[/TD]
[TD]40k[/TD]
[/TR]
[TR]
[TD]eric[/TD]
[TD]m[/TD]
[TD]50[/TD]
[TD]hr[/TD]
[TD]50k[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,823
Messages
6,181,178
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