setting a range variable equal to the value of a string variable

P

Pilgrim

Is it possible to set a range variable as the value of a strin
variable. For instance, I'm trying to set a string variable equal t
the address of several discontiguous cells, then set the a rang
variable equal to the cell locations and put them in a chart. I'v
loaded several cell locations in a string variable so the variable ha
a value like:

StrVar = "A1,A7,A34,A34"

But if I try

RangeVar = Range(StrVar)

or

RangeVar = Range("StrVar")

It tries to evluate StrVar as a cell or cell name. Can I get the rang
mode to use the value of StrVar instead of the variable itself
 
B

Bob Phillips

strVar = "A1,A7,A34,A34"
Set myRange = Range(strVar)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
P

Pilgrim

oops, guess i forgot the "Set" in my post. my code does look like

Set RangeVar = (strVar)

But when I try to set the XValues of a series in a chart, it say
"Unable to set the XValues property of the Series class." And movin
the cursor over the RangeVar variable, it says that RangeVar is equa
to the value of first cell in the range even though it is a rang
variable, not an integer, string, single, or anything else. It seem
that the range is not loading into the variable properly. It eve
seems to be doing this if i set the range directly equal to the strin
of cells I want and not the variable. Any ideas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top