Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
MS Excel: Quick way to put multiple sheets into a single workbook?
I often want to work with many independent text files as excel worksheets, and to organize them into a single workbook is cumbersome (right click worksheet tab, "move or copy", etc., each one).
Is there a shortcut or setting that will allow me to, say, open all the files at once combined into a single workbook? Or to collapse all open workbooks into a single workbook?
To clarify: I CAN, in fact, open files in excel and combine them into a single workbook.
I want to know if there is a quick way that doesn't involve fiddling around with every single separate file in turn (e.g., to make them all open in a single workbook rather than separate notebooks; or to combine all open workbooks into one at once, etc.).
4 Answers
- 1 decade agoFavorite Answer
There is a way to do what you ask,but it requires using some macros. I am not sure how comfortable you are using them, but I wrote you some quick code that will do what you ask. It is not my best work, but I did it relatively quickly so all you coders out there no laughing ;)
To make this work, follow these steps:
1) Open a blank Excel Workbook.
2) Press Alt-F11 on your keyboard to enter the Visual Basic for Applications IDE.
3) From the file menu, click on Insert Module
4) Paste the code that I have below into the module.
5) On the 12th line of code is a line that reads:
MyPath = "c:\text\" ' Set the path.
Replace the path on the quotes with the path that you keep your text files. Be sure to end it with the slash " \ ".
5) Save your Workbook and close the IDE (Alt-Q)
6) From the Excel Worksheet, Alt-F8 to open the Run Macros window.
7) Look in the list for one called 'ReadDir;
8) Select this macro
If all goes well it should open each text file in the directory and move the file into the activeworkbook. It will rename each tab the name of the text file. Hope this meets your needs.
================================
Sub ReadDir()
Dim MyPath As String
Dim MyFile As String
Dim xlrow As Long
Dim txtNumber As Integer
Dim MyWorkbook As String
Dim MyOpenWorkbook As String
Dim fixFileName As String
MyWorkbook = ActiveWorkbook.Name
MyPath = "c:\text\" ' Set the path.
MyFile = Dir(MyPath & "*.txt", vbDirectory)
Do While MyFile <> ""
txtFile = MyPath & MyFile
Workbooks.OpenText Filename:=txtFile, StartRow:= _
1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False
MyOpenWorkbook = ActiveWorkbook.Name
If Right(MyFile, 4) = ".txt" Then
fixFileName = Left(MyFile, Len(MyFile) - 4)
End If
Sheets(fixFileName).Select
Sheets(fixFileName).Copy After:=Workbooks(MyWorkbook).Sheets(1)
Workbooks(MyOpenWorkbook).Close False
MyFile = Dir
Loop
End Sub
- Anonymous5 years ago
Highlight the whole sheet by left clicking on the area (box) in the very top left hand corner of the spreadsheet. (above the "A" and the "1," Copy and paste sheet into new workbook.
- 1 decade ago
you can import or export the sheets or workbook or some selected stuff.....IMPORT / EXPORT
- Anonymous1 decade ago
coy and paste