Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying from several workbooks into one

From the suggestion of a friend, I looked in here for an example to help me with a problem. I found one posted a couple of days ago by Dave Peterson. It seems to work great, but I am looking for some assistance to make a slight modification. I know excel well, but not VBA. Right now it looks like this is looking into a specific folder to get file names. What I would like to be able to do is make it look on a sheet in a specific column and get the file names to combine from there. Say for instance the file names are listed in column "E". Is there a way to make this code look in column "E", and use all the files listed there instead of a specific folder

Option Explici
Sub CombineWorkbooks(
Dim LastRow As Lon
Dim basebook As Workboo
Dim i As Lon
Dim mybook As Workboo
Dim DestCell As Rang
Dim RngToCopy As Rang

With Applicatio
.DisplayAlerts = Fals
.EnableEvents = Fals
.ScreenUpdating = Fals
End Wit
With Application.FileSearc
.NewSearc
'Change this to your director
.LookIn = ThisWorkbook.Path & "\ProgramData\"
.SearchSubFolders = Fals
.FileType = msoFileTypeExcelWorkbook
If .Execute() 0 The
Set basebook = Workbooks.Open(.FoundFiles(1))
With basebook.Worksheets(1
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp
End With
For i = 2 To .FoundFiles.Coun
Set mybook = Workbooks.Open(.FoundFiles(i)
With ActiveShee
'column R = 18th colum
Set RngToCopy = .Range("a1:R" &
.Cells(.Rows.Count, "A").End(xlUp).Row
End With
If (DestCell.Row + RngToCopy.Rows.Count)
< DestCell.Parent.Rows.Count The
'ok to paste, just come down one
Set DestCell = DestCell.Offset(1, 0
Els
'too many rows, make a new shee
Set DestCell = basebook.Worksheets.Add.Range("a1"
End If
RngToCopy.Copy
Destination:=DestCel
Set DestCell = DestCell.Offset(RngToCopy.Rows.Count)
mybook.Clos
Next
'ChDir ThisWorkbook.Path & "\ProgramData\FileData\Report\
ActiveWorkbook.SaveAs
Filename:=ThisWorkbook.Path & "\ProgramData\FileData\Report\"
& "Report1.xls",
FileFormat:=xlNormal, CreateBackup:=Fals
'ActiveWorkbook.Close savechanges:=false 'just save
End I
End Wit
With Applicatio
.DisplayAlerts = Tru
.EnableEvents = Tru
End Wit
End Su

I don't really know if this is something that can be done or not, but if anybody has any ideas, it would be very helpful

Anthony
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying between workbooks Brad Excel Discussion (Misc queries) 2 January 9th 08 08:22 PM
copying workbooks acomputer4u Excel Worksheet Functions 3 November 25th 06 06:29 PM
Copying workbooks Nadji New Users to Excel 4 October 5th 06 03:16 PM
copying workbooks Nadji Excel Worksheet Functions 3 October 4th 06 08:43 PM
Copying from other Workbooks SusieQ Excel Discussion (Misc queries) 0 January 30th 06 12:44 PM


All times are GMT +1. The time now is 03:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"