Import multiple excel files into one master workbook

shwetankbhardwaj

New Member
Joined
Apr 26, 2017
Messages
20
Hi,

I have imported multiple excel files into one master workbook but also want imported files to have its actual name instead of Sheet1..2.. and so on. e.g I have imported two files named "Customer name" and "Quantity" but in master workbook these can be seen as Sheet1 and sheet 2. Please help!

Below is the language I have used to Import files & working successfully.

Sub GetSheets()


Path = "O:\Funds\Other\Sales load activity"
Filename = Dir(Path & "*.xlsx")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Do the files you are trying to import have 1 sheet only?
 
Upvote 0
Ok try this
Code:
Sub GetSheets()

Dim Path As String
Dim FName As String
Dim ShtName As String

Application.ScreenUpdating = False

    Path = "O:\Funds\Other\Sales load activity"
    FName = Dir(Path & "*.xls")
    Do While FName <> ""
        Workbooks.Open FileName:=Path & FName
        ShtName = Left(FName, Len(FName) - 4)
        Sheets(1).Copy After:=ThisWorkbook.Sheets(1)
        Workbooks(FName).Close
        ActiveSheet.Name = ShtName
        FName = Dir()
    Loop

Application.ScreenUpdating = True

End Sub
 
Upvote 0
You are amazing Fluff!

It's working with two minor changes.

1. I changed path from "O:\Funds\Other\Sales load activity" to "O:\Funds\Other\Sales load activity\"
2. File format is changed from "*.xls" to "*.xlsx".

Thanks a lot!!!
 
Upvote 0
Hey Fluff,

I would be needing your help again to find out value based on Sheet name. e.g in sheet1, It's written "Product" in "A2" cell in very next cell "B2" I will be needing an amount from next sheet (sheet name is product "C13". Also have more names listed down in sheet1 after product e.g quantity, Client name in A3 and A4 respectively and also have sheet named quantity and client name).

Thanks,
Shwetank
 
Upvote 0
Will you always be pulling the info from C13?
If not, how do you tell where to get the info from?
 
Upvote 0

Forum statistics

Threads
1,223,675
Messages
6,173,748
Members
452,533
Latest member
Alex19k

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