Alternative formula drag

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I hope someone can help out with this, please?

I've got some code which imports data from ALL files in a folder into different tabs in one file.

However, I'd like to modify this code (below) so that it does the following:

Imports 6 different files from a folder into 1 Summary file, but pastes the data from those files into 6 different tabs in the Summary file.

So

1) Columns A:H from the 1st file to be imported would be pasted into columns A:H of the 1st tab in the Summary file

2) Columns A:F from the 2nd file to be imported would be pasted into columns A:F of the 2nd tab in the Summary file

3) Columns A:C from the 3rd file to be imported would be pasted into columns A:C of the 3rd tab in the Summary file

4) Columns A:D from the 4th file to be imported would be pasted into columns A:D of the 4th tab in the Summary file

5) Columns A:C from the 5th file to be imported would be pasted into columns A:C of the 5th tab in the Summary file then the last one is different:

6) Columns A:C from the 6th file to be imported would be pasted into columns B:F of the 6th tab in the Summary file

Does anyone know how to do this, please?



VBA Code:
Sub FilesInto1SepSheets()

Path = "C:\Users\" & Environ("UserName") & "\Documents\ExcelFilesToImport\"

Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True

For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop

End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I forgot to amend the title of the post, but the edit function won't let me? I wanted to call it 'import data from 6 files into 6 different tabs in one file'

Would it be possible to do that, please, @Fluff ?
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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