I am getting errors and I can not see why.
I have an array looks for matches from the array down a column. When it matches it copys the used range of that row and paste it below the last row on another page.
Dim iCL As Integer, USCurRow As Integer, USlRow As Integer, USlCol As Integer, USlRow2 As Integer
Dim USCountryList(1 To 1) As String
Dim USCtry As String
USCountryList(1) = "Country1"
For iCL = 1 To UBound(USCountryList)
USCtry = USCountryList(iCL)
USlRow = Sheets("US Confirmed").Cells(Rows.Count, 1).End(xlUp).Row
USlCol = Sheets("US Confirmed").Cells(1, Columns.Count).End(xlToLeft).Column
USlRow2 = Sheets("World Confirmed").Cells(Rows.Count, 2).End(xlUp).Row
For USCurRow = 2 To USlRow
If Sheets("US Confirmed").Cells(USCurRow, 1) = USCtry Then
Sheets("World Confirmed").Range(Cells(USlRow2 + 1, 1), Cells(USlRow2 + 1, USlCol)) = _
Sheets("US Confirmed").Range(Cells(USCurRow, 1), Cells(USCurRow, USlCol))
End If
Next USCurRow
Next iCL
I keep getting an application-defined or object-defined error
during the Copy part.
Stepping through the values of the variables appear to be valid:
hard coding them in as such:
Sheets("World Confirmed").Range(Cells(268,1),cells(268,121))= _
Sheets("US Confirmed").Range(Cells(3, 1), Cells(3, 121))
Generates same application-defined or object-defined error
error.
I have also tried range select. selection copy
range select selection paste
and still running into an error