JHags
JHags

Reputation: 11

Copy a range of data and paste it into a separate sheet cell

For some reason, the range only copies over the first two rows starting in A1 on sheet "11937" and I need it to start on cell A2 and copy all data up until column AL and paste that data in sheet "STS" starting at C2.

Please help

With Sheets("11937")
.Range("A2:AL" & Cells(Rows.Count, "B").End(xlUp).Row).CopyDestination:=Sheets("STS").Range("C2")
End With

Upvotes: 1

Views: 106

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149335

Either your Col B is empty or Cells(Rows.Count, "B") is referring to the Activesheet which may not be 11937. Hence it is always advisable to fully qualify your objects.

Here is an example

Dim lRow As Long

With Sheets("11937")
    lRow = .Range("B" & .Rows.Count).End(xlUp).Row

    .Range("A2:AL" & lRow).Copy Destination:=Sheets("STS").Range("C2")
End With

Upvotes: 1

Related Questions