Excel VBA Range and Cells

I have this same problem all the time, and can never remember the solution. Here is the code:

cc = 22
writewrk.Sheets("Characteristics").Range("A20:A48").Value = readwrk.Sheets("Weights").Range("B17:B45").Value
writewrk.Sheets("Characteristics").Range("B20:B48").Value = readwrk.Sheets("Weights").Range(Cells(17, cc), Cells(45, cc)).Value

Open in new window


Line 2 works, but line 3 gives an error. Why is this? What is the correct syntax? Thanks.
LVL 3
sypderAsked:
Who is Participating?
 
Saqib Husain, SyedConnect With a Mentor EngineerCommented:
I think you ought to have

readwrk.Sheets("Weights").

before each of the cells()
0
 
sypderAuthor Commented:
You are exactly right! So simple, yet so hard for me to remember. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.