Lovelylou79
New Member
- Joined
- Sep 4, 2017
- Messages
- 37
Hi Folks,
I am trying to get data from multiple workbooks into 1workbook, building up a large data source.
The code should open each workbook selected, copy cellsA3:AP and last row and then paste into the new workbook at the last blank row.
I am currently struggling with finding the last row to copy to. The code seems correct, and works fine in the individual workbooks, but when using it in the workbook where the data will be stored, it only copies the first 3 rows (A1:AP1 to A3:AP3).
I cant see where it is failing. Any help would be appreciated.
Thanks
I am trying to get data from multiple workbooks into 1workbook, building up a large data source.
The code should open each workbook selected, copy cellsA3:AP and last row and then paste into the new workbook at the last blank row.
I am currently struggling with finding the last row to copy to. The code seems correct, and works fine in the individual workbooks, but when using it in the workbook where the data will be stored, it only copies the first 3 rows (A1:AP1 to A3:AP3).
I cant see where it is failing. Any help would be appreciated.
Code:
Private Sub CommandButton1_Click()
'Import all User data from the various AM Audit Workbooks
Dim FileNameXLs, f
Dim wb As Workbook, i As Integer
Dim lr As Integer
FileNameXLs =Application.GetOpenFilename(filefilter:="Excel Files, *.xl*",MultiSelect:=True)
If Not IsArray(FileNameXLs) Then Exit Sub
Application.ScreenUpdating = False
For Each f In FileNameXLs
Set wb = Workbooks.Open(f)
wb.Worksheets("Sheet1").Range("A3:AP"& Cells(Rows.Count, "B").End(xlUp).Row).CopyThisWorkbook.Sheets("AM_AUDIT_V1").Range("A3")
Application.CutCopyMode = False
wb.Close Savechanges:=False
Next f
Application.ScreenUpdating = True
End Sub
Thanks
Last edited by a moderator: