Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Set a  range to another worksheet using R1C1 format

Posted on 2016-08-12
4
Medium Priority
?
61 Views
Last Modified: 2016-08-12
Hi.

I am having problems getting this right.    Thank you for your help.

    Dim ws As Worksheet:  Set ws = Worksheets("MySheet")
    Dim CCC As Range
    Set CCC = Range(Cells(1, 1), Cells(1, 7))                       ' Seems OK
    Set CCC = Range(ws.Cells(1, 1), ws.Cells(1, 7))                 ' Computer gets angry

Open in new window

0
Comment
Question by:peispud
[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
4 Comments
 
LVL 33

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 2000 total points
ID: 41754136
Try this.....

Set CCC = ws.Range(ws.Cells(1, 1), ws.Cells(1, 7))

Open in new window


When you use only Set CCC = Range(Cells(1, 1), Cells(1, 7)), the range will be set according to the active sheet. While in the syntax above you qualified the cells reference with ws but not with Range so you also need to qualify the Range with the sheet reference, in this case ws.
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 41754139
What worksheet are you using in line 3?  Is MySheet the current sheet, or something else?  The range depends on the worksheet, so the syntax would be like this:

   strRange = "A7:A10"
   Set rngPipeline = shtPipeline.Range(strRange)
   rngPipeline.Select

Open in new window

0
 

Author Closing Comment

by:peispud
ID: 41754169
Perfect!!    Thank all for helping.
0
 
LVL 33

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41754172
You're welcome. Glad to help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

636 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