Copy list of workbooks ( one sheet only) to one workbook in tab number order

David123456

New Member
Joined
Jul 16, 2014
Messages
48
Can anyone assist with a formula.

Take a list of workbooks ( only1 worksheet in each workbook) say the workbooks are held in the y:\ and called 1980-001,1980-002 up to 1980-250

I want to copy all these individual workbooks to one workbook in tabs in file number order.

So the first tab would be 1980-001 the next tab would be 1980-002 and so on depending o how many workbooks there are.

My formula doe this but does not add the workbook name to the tab and also does not copy them over in number order.


Any help greatly appreciated
 
Silly me. How about?

Code:
Sub GetSheets()
    Dim Path As String
    Dim Filename As String
    Dim ShName As String
    Path = "Y:"
    Filename = Dir(Path & "*.xls")
    Do While Filename <> ""
        Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
        ShName = Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, ".") - 1)
        ActiveWorkbook.Worksheets(1).Copy After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
        ActiveSheet.Name = ShName
        Workbooks(Filename).Close
        Filename = Dir()
    Loop
End Sub
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,216,038
Messages
6,128,450
Members
449,453
Latest member
jayeshw

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