Bill
Maybe something like this is what you want. HTH Otto
This macro will copy the first sheet of each workbook into the
workbook where the code is.
The sheet will be named as the workbook name.
Sub TestFile3()
Dim basebook As Workbook
Dim mybook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String
SaveDriveDir = CurDir
MyPath = "C:\Data"
ChDrive MyPath
ChDir MyPath
FNames = Dir("*.xls")
If Len(FNames) = 0 Then
MsgBox "No files in the Directory"
ChDrive SaveDriveDir
ChDir SaveDriveDir
Exit Sub
End If
Application.ScreenUpdating = False
Set basebook = ThisWorkbook
Do While FNames < ""
Set mybook = Workbooks.Open(FNames)
mybook.Worksheets(1).Copy after:= _
basebook.Sheets(basebook.Sheets.Count)
On Error Resume Next
ActiveSheet.Name = mybook.Name
On Error GoTo 0
' You can use this if you want to copy only the values
' With ActiveSheet.UsedRange
' .Value = .Value
' End With
mybook.Close False
FNames = Dir()
Loop
ChDrive SaveDriveDir
ChDir SaveDriveDir
Application.ScreenUpdating = True
End Sub
"Bill Coupe" wrote in message
...
I know there has to be a simple way to do this, but I can't seem to find
it.
What I want to do is to open an existing Excel file, 'into' the current
(ActiveSheet) of an already open file.
The way I found to do it was to use the 'Data\Import External Data'
option.
My ultimate goal here is to 'gather up' a set of recently generated
spreadsheets (each containing only one worksheet) into one Excel file
contaiing all the individual files from within a VFP application.
But having to add a 'Connection' to native data just doesn't seem right to
me...
I'd love to hear anyone's thoughts on this.
Thanks - Bill
|