Below is my code using array to have data from SW to DW.Code is not throwing any error but data is also not pasted in to DW. What I am trying to do is to find AG-last row of data in SW and then assign it to Arr and trying to copy the same in to DW. My source workbook is in my C drive.
Sub Arr()
Dim SW AS Workbook
Dim DW As Worksheet
Dim Arr as Variant
Set DW = ThisWorkbook.Sheets("Sample")
Set SW = Workbooks.Open ("C:\User\filename.xlsx")
Lastrow = SW.Sheets("data").Cells(Rows.Count, "A").End(xlUP).Row
Arr = SW.Sheets("data").Range("A3:AG" & Lastrow)
DW.Range("A2").Value = Arr
End Sub
Try
DW.Range("A2").resize(ubound(arr,1),ubound(arr,2)).Value = Arr
You are trying to put the whole array into one cell.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.