Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel VBA Range and Cells

Posted on 2013-11-26
2
Medium Priority
?
313 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
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

926 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