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
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi Andrew

Firstly thanks for replying.

The formula was on my original thread on my first request.

Also could you recommend any books just starting to get going with Macros. Enjoying it and don't mind putting in the hard work.

Thanks

David
 
Upvote 0
Thanks Andrew.

The formula I provide above does put the worksheets in the workbook automatically and on individual tabs.

Just needed to know what I needed to include in the formula to make sure it copies the worksheets in order in individual tabs. But also names the tabs.
 
Upvote 0
Hi Andrew,

Can send direct from my own E Mail. As I cannot copy and paste in this version.

I can mail you my E Mail
 
Upvote 0
Sub GetSheets()
Path = "Y:"
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
 
Upvote 0
Try:

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

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

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