-1

I'm getting the infamous Run-time error when I run this code, and I don't understand why:

With ThisWorkbook.Sheets("Data") .Range(Cells(row1, column1), Cells(row2, column1)).Copy End With

row1, column1 and row2 are all defined as Integers.

The error pops up for the second line of code.

Can I get some insight please?

2 Answers2

1

You forgot the "." before Cells (as you are within the With scope of the Sheet Data)

With ThisWorkbook.Sheets("Sheet2")
    .Range(.Cells(1, 1), .Cells(2, 2)).Copy
End With

Tested the above example and now it works for me.

AnalystCave.com
  • 4,884
  • 2
  • 22
  • 30
0

Where are you coping the range to. The proper format is

source.copy destination

Sheets("Count").Range("C2:D3").Copy Sheets("Count").Range("E2:F3")
MatthewD
  • 6,719
  • 5
  • 22
  • 41