Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel VBA Range and Cells

Posted on 2013-11-26
2
Medium Priority
?
310 Views
Last Modified: 2013-11-26
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.
0
Comment
Question by:sypder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 39679372
I think you ought to have

readwrk.Sheets("Weights").

before each of the cells()
0
 
LVL 3

Author Comment

by:sypder
ID: 39679424
You are exactly right! So simple, yet so hard for me to remember. Thanks.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question