I am trying to copy data from wsCL2
in Column A
starting from cell A2
down to whenever the data ends; the number of rows can vary.
I want to paste into Column A
of coSummary
, from the next empty cell in that column.
Sub Test()
Dim wb As Workbook
Dim wsCL2 As Worksheet
Dim summary As Worksheet
Dim colLastRow As Long
Dim summaryLastRow As Long
Set wb = ActiveWorkbook
Set wsCL2 = wb.Sheets("Tocopyfrom")
Set summary = wb.Sheets("Summary")
'Defining last row of data in Colliers
summaryLastRow = summary.Cells(Rows.Count, 1).End(xlUp).Row
colLastRow = wsCL2.Cells(Rows.Count, 1).End(xlUp).Row
summary.Cells(10, 10).Value = colLastRow
summary.Cells(11, 10).Value = summaryLastRow
'Copying range from Colliers to Summary Page (***ERROR HERE***)
wsCL2.Range(Cells(2, "A").Address(), Cells(colLastRow, "A")) _
.Copy summary.Cells(summaryLastRow + 1, "A")
colLastRow = summary.Cells(Rows.Count, 1).End(xlUp).Row
End Sub
It sometimes throws an error when trying the Copy
method; other times it will execute properly.
I suspect it's related to refreshing the values for the summaryLastRow
value or to D
?
Thanks!