• 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
 
Back
Top