I have written code to open data and select a file/s and then to copy the data from sheet1 to sheet imported data
When running the macro, I get run time error-Application defined or object defined error
The following part of the code is highlighted
.Sheets(1).UsedRange.Copy Destination:=ThisWorkbook.Sheets("Imported Data").Range("A" & Rows.Count).End(xlUp).Offset(1)
See full code below
Sub Open_Workbook()
A:
Dim A As Variant
ChDir "C:\extract"
A = Application.GetOpenFilename
If A = False Or IsEmpty(A) Then Exit Sub
Application.ScreenUpdating = False
With Workbooks.Open(A)
.Sheets(1).UsedRange.Copy Destination:=ThisWorkbook.Sheets("Imported Data").Range("A" & Rows.Count).End(xlUp).Offset(1)
.Close False
End With
answer = MsgBox("Does another file needs to be selected?", vbYesNo + vbQuestion, "Hello")
If answer = vbYes Then
GoTo A:
End If
Application.ScreenUpdating = True
End Sub
I have attached my destination workbook containing the macro "Import Payment Data.xls" as well as my source workbook
It would be appreciated if someone could assist me
Bookmarks