0

I'm having some trouble with my code:

Worksheets("Week 1").Range(Cells(4, ColNo), Cells(5, ColNo)).Value = Worksheets("Count").Range(Cells(4, 2), Cells(5, 2)).Value

If I change it to

Worksheets("Week 1").Range(Cells(4, ColNo), Cells(5, ColNo)).Value = Worksheets("Count").Range("B4:B5").Value

It works fine, can anyone help?

Cr1kk0
  • 83
  • 2
  • 14

1 Answers1

0

I fixed this by adding .address after the cells

Worksheets("Count").Range(Cells(4, 2).address, Cells(5, 2).address).Value
Cr1kk0
  • 83
  • 2
  • 14
  • If that code runs when the active sheet is a `Chart`, it will fail because a `Chart` sheet doesn't have `Cells`. It is better to fully qualify the references, e.g. as `Worksheets("Count").Range(Worksheets("Count").Cells(4, 2), Worksheets("Count").Cells(5, 2)).Value` (or using a `With Worksheets("Count")` block, `.Range(.Cells(4, 2), .Cells(5, 2)).Value`) – YowE3K Feb 27 '17 at 01:06