View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default ***PLease help. Need to Merge directory of files into one file.***

Sub consolidatebooks()
Dim sh as Worksheet
Dim sPath as String, sName as String
Dim bk as workbook
set sh = Activesheet
sh.cells.clearcontents
sPath = "C:\Myfolder\"
sName = dir(sPath & "*.xls")
do while sName < ""
set bk = workbooks.Open(sPath & sname)
' copy sheets?
'bk.worksheets.copy After:= _
thisworkbook.Worksheets(thisworbook.worksheets.cou nt)
' copy some data
' bk.worksheets(1).Range("A1").currentRegion.copy _
sh.cells(rows.count,1).End(xlup)(2)
bk.close SaveChanges:=False
sname = dir()
Loop
End Sub

--
Regards,
Tom Ogilvy

"Shani" wrote:

I have a bunch of excel files stored in c:/temp. I want to merge all of
these files into one excel spreadsheet.