I am trying to copy specific cells from one workbook to another at the end of the table. I assume the problem is with using 'ActiveWorkbook' a lot. I get the error "Object doesnt support this property or method" and it seems that macro copies cells from CurrentBook and not uploader.
How can I fix my code?
Dim uploadfile As Variant
Dim uploader As Workbook
Dim CurrentBook As Workbook
Dim lastRow As Integer
Set CurrentBook = ActiveWorkbook
uploadfile = Application.GetOpenFilename()
If uploadfile = "False" Then
Exit Sub
End If
Workbooks.Open uploadfile
Set uploader = ActiveWorkbook
With uploader
Application.CutCopyMode = False
Range("A1:J100").Copy
End With
CurrentBook.Activate
lastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1
Range("A" & lastRow & ":J" & lastRow + 100).Select
Selection.Paste
uploader.Close
End Sub