Peterson3000
New Member
- Joined
- Jan 11, 2019
- Messages
- 1
Hi Community
I would like to explore the possibility of copying data from different workbooks to a Master sheet.
Based on some of the threads, i have tried the following code:
Sub CopyRange()
Application.ScreenUpdating = False
Dim wkbDest As Workbook
Dim wkbSource As Workbook
Set wkbDest = ThisWorkbook
Dim LastRow As Long
Const strPath As String = "C:\Users\Peterson\Desktop\group1"
ChDir strPath
strExtension = Dir("*.xls*")
Do While strExtension <> ""
Set wkbSource = Workbooks.Open(strPath & strExtension)
With wkbSource
LastRow = .Sheets("appendix B").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Sheets("appendix B").Range("C7:F15").Copy wkbDest.Sheets("Master").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0)
.Close savechanges:=False
End With
strExtension = Dir
Loop
Application.ScreenUpdating = True
End Sub
However, i would like the data to be copied horizontally in the Mastersheet.
Your advice is greatly appreciated.
Thanks.
Peterson
I would like to explore the possibility of copying data from different workbooks to a Master sheet.
Based on some of the threads, i have tried the following code:
Sub CopyRange()
Application.ScreenUpdating = False
Dim wkbDest As Workbook
Dim wkbSource As Workbook
Set wkbDest = ThisWorkbook
Dim LastRow As Long
Const strPath As String = "C:\Users\Peterson\Desktop\group1"
ChDir strPath
strExtension = Dir("*.xls*")
Do While strExtension <> ""
Set wkbSource = Workbooks.Open(strPath & strExtension)
With wkbSource
LastRow = .Sheets("appendix B").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Sheets("appendix B").Range("C7:F15").Copy wkbDest.Sheets("Master").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0)
.Close savechanges:=False
End With
strExtension = Dir
Loop
Application.ScreenUpdating = True
End Sub
However, i would like the data to be copied horizontally in the Mastersheet.
Your advice is greatly appreciated.
Thanks.
Peterson