Inserting Data: Multiple Sheets



I'm using the code below to retreive data from multiple workbooks. However when the data is received, it deletes the headings that I have in place. What can I add that will place the data in a particular sheet and cell number on the new worksheet receiving the information. Thank

Sub TestFile4(
Dim basebook As Workboo
Dim mybook As Workboo
Dim sourceRange As Rang
Dim destrange As Rang
Dim rnum As Lon
Dim a As Lon
Dim FNames As Strin
Dim MyPath As Strin
Dim SaveDriveDir As Strin

SaveDriveDir = CurDi
MyPath = "X:\Reports2K\Reports\Daily\sg
ChDrive MyPat
ChDir MyPat
FNames = Dir("*.xls"
If Len(FNames) = 0 The
MsgBox "No files in the Directory
ChDrive SaveDriveDi
ChDir SaveDriveDi
Exit Su
End I

Application.ScreenUpdating = Fals
Set basebook = ThisWorkboo
rnum =
Do While FNames <> "
If Left(FNames, 18) = "SuperGroup2_200402" The
Set mybook = Workbooks.Open(FNames
Set sourceRange = mybook.Worksheets(2).Range("B45:N45"
a = sourceRange.Rows.Coun
Set destrange = basebook.Worksheets(2).Cells(rnum, 1

sourceRange.Copy destrang
rnum = rnum +
mybook.Close Fals
End I
FNames = Dir(
ChDrive SaveDriveDi
ChDir SaveDriveDi
Application.ScreenUpdating = Tru
End Sub

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question