ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting Data: Multiple Sheets (https://www.excelbanter.com/excel-programming/291779-inserting-data-multiple-sheets.html)

Ramon

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(
Loo
ChDrive SaveDriveDi
ChDir SaveDriveDi
Application.ScreenUpdating = Tru
End Sub

Ramon

Inserting Data: Multiple Sheets: Disregard
 
Please disregard last post. Thanks


All times are GMT +1. The time now is 05:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com