Hi Everyone,
I'm trying to copy some specific cells e.g. (from sheet1) A2,A4,B2,B4,C6,C8 to another sheet.
but all that data should be pasted in a row, (in sheet2) columns A, B, C, D, E, F and on the next empty row.
Manage to find someone online trying to accomplish something similar in year 2004 and i try to follow the code but it
get a run-time error " Run-Time Error '1004': Application-Defined or Object-Defined error " and no follow-up if the code is working.
Can someone help to advice? Thanks
I'm trying to copy some specific cells e.g. (from sheet1) A2,A4,B2,B4,C6,C8 to another sheet.
but all that data should be pasted in a row, (in sheet2) columns A, B, C, D, E, F and on the next empty row.
Manage to find someone online trying to accomplish something similar in year 2004 and i try to follow the code but it
get a run-time error " Run-Time Error '1004': Application-Defined or Object-Defined error " and no follow-up if the code is working.
Can someone help to advice? Thanks
Code:
Sub Get_Data()
Dim lastrowSheet2 As Long, lastrow As Long
Dim arr1, arr2, i As Integer
With Worksheets("Sheet2")
lastrowSheet2 = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
End With
arr1 = Array("B2", "B4", "B6", "D2", "D4", "D6")
arr2 = Array("A", "B", "C", "D", "E", "F")
For i = LBound(arr1) To UBound(arr1)
With Sheets("Sheet1")
lastrow = Application.Max(3, .Cells(.Rows.Count, Left(arr1(i), 1)).End(xlUp).Row)
Sheets("Sheet2").Range(arr2(i) & lastrowDB).Resize(lastrow - 2).Value = _
.Range(.Cells(3, arr1(i)), .Cells(lastrow, arr1(i))).Value
End With
Next
Application.CutCopyMode = False
End Sub