• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Code snippet to extract worksheets

Sorry, a correction..

Just wondering if there is a possible flow to move/copy worksheets from 2 or multiple workbooks which are saved in a folder? Thanks


Hi,

Just wondering if there is a possible flow to get worksheet names from 2 or multiple workbooks which are saved in a folder?

Sub SheetNames()
Columns(1).Insert
For i = 1 To Sheets.Count
Cells(i, 1) = Sheets(i).Name
Next i
End Sub

Thanks in advance,
Karthik
 
Last edited:
Presumably, you would have the Master file open and then use one of the "Merge data from all workbooks in a folder" macros. Or, you can use the RDBMerge Add-in
 
Once you've got the looping setup, code would be something like:
Code:
'already in a loop
set wb = workbooks.open(myFile)
'This is the line to copy worksheet
wb.Worksheets(1).Copy ThisWorkbook.Worksheets(thisworkbook.Worksheets.Count)
'Close the other workbook
ws.Close SaveChanges:=False
'continue loop
 
Hi,

Please see the attached file.

Presently, I've this which opens up file explorer, once we select the folder, that should copy worksheets to the activeworkbook.

Can you help?
 

Attachments

  • Browse & copy sheets to ThisWorkBook.xlsm
    23.3 KB · Views: 1
Chopped out the stuff that was in the loop, replaced it with snippet. Attached is a workinig file, able to merge all worksheets from all XL files in selected folder.
 

Attachments

  • Browse & copy sheets to ThisWorkBook LM.xlsm
    54.5 KB · Views: 3
Back
Top