Solved

Set a  range to another worksheet using R1C1 format

Posted on 2016-08-12
4
33 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
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 500 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 28

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Excel filter by strike though 8 26
TT Copy Formula 3 16
Excel 2016 Hiding Toolbars 7 23
Insert rows based on cell value vba 3 12
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now