0

Simple question. Why does this code give an error?

Sheet1.Range("A1:I14").Copy Sheet2.Range("A1").PasteSpecial

Sheet2.Range("A1:X14").Select
J. Hill
  • 33
  • 6
  • 1
    Because you can't select cells on an inactive sheet, you need to activate sheet first. But read https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba – SJR Mar 24 '20 at 10:13
  • If You MUST use `.Select` first select `Sheet2`, then range on that second sheet – Teamothy Mar 24 '20 at 10:21
  • On which line do you get an error? – Storax Mar 24 '20 at 10:33

1 Answers1

0

Try simple using of the next code. No selection necessary for such a task:

Dim rng As Range
  Set rng = sheet1.Range("A1:I14")
   Sheet3.Range("A1").Resize(rng.Rows.Count, rng.Columns.Count).value = rng.value
FaneDuru
  • 38,298
  • 4
  • 19
  • 27