Thread: Merging Files
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Merging Files

WB.Worksheets(1).Rows(2).Copy Destination:=Dest

This will copy from the first worksheet( It use the sheet index)

If the worksheet names in the files have the same name you can use this
WB.Worksheets("yoursheet").Rows(2).Copy Destination:=Dest

I have also a example on this page
http://www.rondebruin.nl/copy3.htm




--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"rglasunow " wrote in message ...
Someone helped me with the code to merge all the files under one folder
onto one spreadsheet. However, from the code below is there a way I
can tell Excel to open a file and copy from a specific worksheet?

Application.ScreenUpdating = False
Dim FName As String
Dim WB As Workbook
Dim Dest As Range
Const FOLDERNAME = "" ChDrive FOLDERNAME
ChDir FOLDERNAME

Set Dest = Range("A2")
FName = Dir("*.xls")

Do Until FName = ""
Set WB = Workbooks.Open(FName)
WB.Worksheets(1).Rows(2).Copy Destination:=Dest
WB.Close savechanges:=False
Set Dest = Dest(2, 1)
FName = Dir()
Loop
End Sub

Thank you!!


---
Message posted from http://www.ExcelForum.com/