0

I am copying data from one sheet to another one but runtime error 1004 occur it is due to active sheet problem. as code is for sheet 2 and 3 and during execution if I stay on sheet1 this error occurred. I need sheet1 also for work

use active sheet, select sheet but not solved

Sub T()
    'Set wksSource = ActiveWorkbook.Sheets("Sheet3")
    Sheets("sheet3").Range(Range("A1"), Range("A1").End(xlDown)).Copy
    Sheets("sheet2").Cells(1, 1).PasteSpecial Paste:=xlPasteAll, Transpose:=True
End Sub

the code runs despite location of sheet

deHaar
  • 17,687
  • 10
  • 38
  • 51
  • 3
    You need to qualify the worksheet that `Range("A1")` is on. A `With...End With` block is a good way to do so. See the answer in [this question](https://stackoverflow.com/questions/17733541/why-does-range-work-but-not-cells). – BigBen Oct 22 '19 at 12:59
  • 3
    Possible duplicate of [Why does Range work, but not Cells?](https://stackoverflow.com/questions/17733541/why-does-range-work-but-not-cells) – Foxfire And Burns And Burns Oct 22 '19 at 14:47

0 Answers0